i got following script. (suprisingly, it works...sometimes). just filling the table from input is not fully done yet.
i want to change behaviour, so the cells are selected/unselected, only when mouse button is pressed.
i removed all the code with global variable selMousePressed, so it should be clean of all my experiments.
should work in ie 5.5+, mozilla.
thx
--------------------------
----------
---------
<html>
<head>
<script type="text/javascript">
var bgColor='white', selColor= 'red'
function createSelector(idInput){
res='<table id= "selector' + idInput+ '" style="border-width:0;font
-size:x-sm
all;" ><tr>';
for(i=0;i<24;i++){
res=res+'<td style="background-color:'+
bgColor+';
cursor:poi
nter;curso
r:hand;mar
gin:0px;pa
dding:0px;
border-rig
ht: solid black thin;" id="selector'+idInput+ i +'" onmouseover=selectorSwap("
selector'+
idInput+ i+'")>'+(i<10?'0'+i: i)+'</td>';
}
res= res+"</tr></table>";
return( res);
}
function selectorToInput(id){
tmpI= document.getElementById( id);
res='';
for(i=0;i<24;i++){
tmp='selector'+id+i;
tmp= document.getElementById( tmp);
if( tmp.style.backgroundColor=
=selColor)
res=res+ tmp.innerHTML+',';
}
tmpI.value=res;
}
function selectorSwap(id){
tmp= document.getElementById( id);
tmp.style.backgroundColor=
(tmp.style.backgroundColor
== bgColor ? selColor: bgColor);
selectorToInput('i2');
}
function inputToSelector(id){
tmp=document.getElementByI
d( id);
inputStr= new String ( tmp.value);
selArr= inputStr.split(',');
for(i=0;i<selArr.length;i+
+){
tmp='selector'+id+(selArr[
i]<10?'0'+
selArr[i]:
selArr[i]);
tmp= document.getElementById( tmp);
tmp.style.backgroundColor=
selColor;
}
}
</script>
</head>
<body>
<input id= 'i2' type= 'text' value='' />
<div id='x'></div>
<span onclick='inputToSelector("
i2")'>fill
Sel</span>
<script type="text/javascript">
tmp= document.getElementById('x
');
tmp.innerHTML= createSelector('i2');
</script>
</body>
</html>
Start Free Trial