t_kio
06-13-2008, 03:48 PM
Hi,
I'm trying to create a rollover menu, here's the code:
var old_menuname="";
function MenuRollOver(menuname,direction) {
if(direction == "over" && document.getElementById(menuname).src != eval(menuname+"3").src) {
document.getElementById(menuname).src = eval(menuname+"2").src;
}
else if(direction == "out" && document.getElementById(menuname).src != eval(menuname+"3").src) {
document.getElementById(menuname).src = eval(menuname+"1").src;
}
else if(direction == "click" && document.getElementById(menuname).src != eval(menuname+"3").src) {
document.getElementById(menuname).src = eval(menuname+"3").src;
eval('document.getElementById("'+old_menuname+'").src') = eval(old_menuname+"1").src;;
old_menuname=menuname;
}
}
P.S. <menuname>1 = idle button, <menuname>2 = rollover button, <menuname>3 = clicked button.
The first and second condition works just fine, but the third (in bold)
does not. The idea is... I take note on what button is being clicked
by ID, and then switch that button back to its original (unclicked)
image when a new button is clicked.
What drives me nuts is... I can't use the variable old_menuname!
I think it's a scope (global vs non-global) issue but I'm not sure... :(
Any help would me MUCH appreciated.
This is my first post, btw... Thanks in advanced.
t_kio
I'm trying to create a rollover menu, here's the code:
var old_menuname="";
function MenuRollOver(menuname,direction) {
if(direction == "over" && document.getElementById(menuname).src != eval(menuname+"3").src) {
document.getElementById(menuname).src = eval(menuname+"2").src;
}
else if(direction == "out" && document.getElementById(menuname).src != eval(menuname+"3").src) {
document.getElementById(menuname).src = eval(menuname+"1").src;
}
else if(direction == "click" && document.getElementById(menuname).src != eval(menuname+"3").src) {
document.getElementById(menuname).src = eval(menuname+"3").src;
eval('document.getElementById("'+old_menuname+'").src') = eval(old_menuname+"1").src;;
old_menuname=menuname;
}
}
P.S. <menuname>1 = idle button, <menuname>2 = rollover button, <menuname>3 = clicked button.
The first and second condition works just fine, but the third (in bold)
does not. The idea is... I take note on what button is being clicked
by ID, and then switch that button back to its original (unclicked)
image when a new button is clicked.
What drives me nuts is... I can't use the variable old_menuname!
I think it's a scope (global vs non-global) issue but I'm not sure... :(
Any help would me MUCH appreciated.
This is my first post, btw... Thanks in advanced.
t_kio