WolfShade
04-22-2005, 04:12 PM
I have this very nice script for selecting a value from a horizontal graph; click an area and the value is set in a hidden field, as well as changing the image in that area to indicate that it has been 'chosen'.
It works fantastic in IE, but not Mozilla/Netscrape/Opera/FireFox; it won't even do the 'rollover' effects in Mozilla, much less set a value. I suspected that it might be because Mozilla is nit-picky about javascript whereas IE is a little more forgiving, esp. if the object ID is being dynamically set.
If anyone could glance at the code and tell me why it won't work in Mozilla, I'd greatly appreciate it. I'll attach it below my sig (there are two functions.)
Thanks,
WolfShade
^_^
============================
(In this one, an anchor mouseover and mouseout refer to this: a is row, b is index in that row, c is borderColor to change to)
function overBorder(a,b,c) {
thsID = document.getElementById("i"+a+"_"+b);
thsID.style.borderColor=c;
}
(In this one, onMouseUp passes row and index only; the image to be changed to is in the script)
function chooseBorder(a,b) {
for(z=0;z<=31;z++) {
switch(z) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
document.getElementById("i"+a+"_"+z).src="_images/ratings-novice-CFCF65.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="CFCF65";
break;
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
document.getElementById("i"+a+"_"+z).src="_images/ratings-advancedbeginner-FFCC66.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="FFCC66";
break;
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
document.getElementById("i"+a+"_"+z).src="_images/ratings-competent-FF9A65.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="FF9A65";
break;
case 31:
document.getElementById("i"+a+"_"+z).src="_images/ratings-proficient-CCCCCC.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="CCCCCC";
break;
default:
document.getElementById("i"+a+"_"+z).src="_images/pixel-FFFFFF.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="FFFFFF";
break;
}
}
document.getElementById("i"+a+"_"+b).src="_images/pixel-000000.gif";
kd = eval("document.learningplan_step3.keyd"+a); kd.value=b;
}
It works fantastic in IE, but not Mozilla/Netscrape/Opera/FireFox; it won't even do the 'rollover' effects in Mozilla, much less set a value. I suspected that it might be because Mozilla is nit-picky about javascript whereas IE is a little more forgiving, esp. if the object ID is being dynamically set.
If anyone could glance at the code and tell me why it won't work in Mozilla, I'd greatly appreciate it. I'll attach it below my sig (there are two functions.)
Thanks,
WolfShade
^_^
============================
(In this one, an anchor mouseover and mouseout refer to this: a is row, b is index in that row, c is borderColor to change to)
function overBorder(a,b,c) {
thsID = document.getElementById("i"+a+"_"+b);
thsID.style.borderColor=c;
}
(In this one, onMouseUp passes row and index only; the image to be changed to is in the script)
function chooseBorder(a,b) {
for(z=0;z<=31;z++) {
switch(z) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
document.getElementById("i"+a+"_"+z).src="_images/ratings-novice-CFCF65.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="CFCF65";
break;
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
document.getElementById("i"+a+"_"+z).src="_images/ratings-advancedbeginner-FFCC66.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="FFCC66";
break;
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
document.getElementById("i"+a+"_"+z).src="_images/ratings-competent-FF9A65.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="FF9A65";
break;
case 31:
document.getElementById("i"+a+"_"+z).src="_images/ratings-proficient-CCCCCC.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="CCCCCC";
break;
default:
document.getElementById("i"+a+"_"+z).src="_images/pixel-FFFFFF.gif";
document.getElementById("i"+a+"_"+z).style.borderColor="FFFFFF";
break;
}
}
document.getElementById("i"+a+"_"+b).src="_images/pixel-000000.gif";
kd = eval("document.learningplan_step3.keyd"+a); kd.value=b;
}