suicidalkatt
09-01-2007, 08:05 AM
Hi there... my first post and i'm asking for help :(
I'm working on a menu for a website I'm working on and I can't get the button mouseOver effect to work. Only the first button works. Any ideas as to what I might have done wrong?? I'm very new to Javascript and I'm SUPER noob!!
Ok here's my script:
<Script>
button1up = new Image; button1up.src = "images/home.gif";
button1down = new Image; button1down.src = "images/home_up.gif";
button2up = new Image; button2up.src = "images/products.gif";
button2down = new Image; button2down.src = "images/products_up.gif";
button3up = new Image; button3up.src = "images/promotions.gif";
button3down = new Image; button3down.src = "images/promotions_up.gif";
button4up = new Image; button4up.src = "images/contactus.gif";
button4down = new Image; button4down.src = "images/contactus_up.gif";
button5up = new Image; button5up.src = "images/warranty.gif";
button5down = new Image; button5down.src = "images/warranty_up.gif";
//MouseOver
function MouseOverRoutine(ButtonName)
{
if (ButtonName=="button1")
{document.button1.src = button1down.src;}
}
{
if (ButtonName=="button2")
{document.button2.src = button2down.src;}
}
{
if (ButtonName=="button3")
{document.button3.src = button3down.src;}
}
{
if (ButtonName=="button4")
{document.button4.src = button4down.src;}
}
{
if (ButtonName=="button5")
{document.button5.src = button5down.src;}
}
//MouseOut
function MouseOutRoutine(ButtonName)
{
if (ButtonName=="button1")
{document.button1.src = button1up.src;}
}
{
if (ButtonName=="button2")
{document.button2.src = button2up.src;}
}
{
if (ButtonName=="button3")
{document.button3.src = button3up.src;}
}
{
if (ButtonName=="button4")
{document.button4.src = button4up.src;}
}
{
if (ButtonName=="button5")
{document.button5.src = button5up.src;}
}
</script>
Here's my buttons:
<a href="main.html" onmouseOver="MouseOverRoutine('button1')" onmouseOut="MouseOutRoutine('button1')" target="content">
<Img Src="images/home.gif" name="button1" border="0" ></a>
<a href="products.html" onmouseOver="MouseOverRoutine('button2')" onmouseOut="MouseOutRoutine('button2')" target="content">
<Img Src="images/products.gif" name="button2" border="0" ></a>
<a href="promotions.html" onmouseOver="MouseOverRoutine('button3')" onmouseOut="MouseOutRoutine('button3')" target="content">
<Img Src="images/promotions.gif" name="button3" border="0" ></a>
<a href="contactus.html" onmouseOver="MouseOverRoutine('button4')" onmouseOut="MouseOutRoutine('button4')" target="content">
<Img Src="images/contactus.gif" name="button4" border="0" ></a>
<a href="warranty.html" onmouseOver="MouseOverRoutine('button5')" onmouseOut="MouseOutRoutine('button5')" target="content">
<Img Src="images/warranty.gif" name="button5" border="0" ></a>
Thank you so much for your help!!
I'm working on a menu for a website I'm working on and I can't get the button mouseOver effect to work. Only the first button works. Any ideas as to what I might have done wrong?? I'm very new to Javascript and I'm SUPER noob!!
Ok here's my script:
<Script>
button1up = new Image; button1up.src = "images/home.gif";
button1down = new Image; button1down.src = "images/home_up.gif";
button2up = new Image; button2up.src = "images/products.gif";
button2down = new Image; button2down.src = "images/products_up.gif";
button3up = new Image; button3up.src = "images/promotions.gif";
button3down = new Image; button3down.src = "images/promotions_up.gif";
button4up = new Image; button4up.src = "images/contactus.gif";
button4down = new Image; button4down.src = "images/contactus_up.gif";
button5up = new Image; button5up.src = "images/warranty.gif";
button5down = new Image; button5down.src = "images/warranty_up.gif";
//MouseOver
function MouseOverRoutine(ButtonName)
{
if (ButtonName=="button1")
{document.button1.src = button1down.src;}
}
{
if (ButtonName=="button2")
{document.button2.src = button2down.src;}
}
{
if (ButtonName=="button3")
{document.button3.src = button3down.src;}
}
{
if (ButtonName=="button4")
{document.button4.src = button4down.src;}
}
{
if (ButtonName=="button5")
{document.button5.src = button5down.src;}
}
//MouseOut
function MouseOutRoutine(ButtonName)
{
if (ButtonName=="button1")
{document.button1.src = button1up.src;}
}
{
if (ButtonName=="button2")
{document.button2.src = button2up.src;}
}
{
if (ButtonName=="button3")
{document.button3.src = button3up.src;}
}
{
if (ButtonName=="button4")
{document.button4.src = button4up.src;}
}
{
if (ButtonName=="button5")
{document.button5.src = button5up.src;}
}
</script>
Here's my buttons:
<a href="main.html" onmouseOver="MouseOverRoutine('button1')" onmouseOut="MouseOutRoutine('button1')" target="content">
<Img Src="images/home.gif" name="button1" border="0" ></a>
<a href="products.html" onmouseOver="MouseOverRoutine('button2')" onmouseOut="MouseOutRoutine('button2')" target="content">
<Img Src="images/products.gif" name="button2" border="0" ></a>
<a href="promotions.html" onmouseOver="MouseOverRoutine('button3')" onmouseOut="MouseOutRoutine('button3')" target="content">
<Img Src="images/promotions.gif" name="button3" border="0" ></a>
<a href="contactus.html" onmouseOver="MouseOverRoutine('button4')" onmouseOut="MouseOutRoutine('button4')" target="content">
<Img Src="images/contactus.gif" name="button4" border="0" ></a>
<a href="warranty.html" onmouseOver="MouseOverRoutine('button5')" onmouseOut="MouseOutRoutine('button5')" target="content">
<Img Src="images/warranty.gif" name="button5" border="0" ></a>
Thank you so much for your help!!