Trouble with hover buttons.

They have: 21 posts

Joined: Mar 2000

Could someone please go to my <a href="http://www.angelfire.com/nm/TheRock/test.html">test page</a> and tell me what I did wrong. I just cant get the 1st pic to change into the 2nd pic. Thanks.

They have: 67 posts

Joined: Aug 1999

Hi Rock,
2 little things preventing your script form working.
1) you have your initial image and your mouse over image as enter1.gif . you mouse over image should be enter2.gif and your mouse off image should be enter1.gif.
2) The part of the script that is causing you the errors is this part...under your function lightup it reads..

if (document.images)
{
imgOn=eval(imagName + "on.src");
document[imgName].src= imgOn;
}

there should be no "a" in imagName
take that out and it will run as smooth as.

~~~~~~~~~~~~~~~~~~~~~~
your script corrected
~~~~~~~~~~~~~~~~~~~~~~~~
<script language="javascript">
<!--
if (document.images)
{
pic1on= new Image(94,27);
pic1on.src="enter2.gif";

pic1off= new Image(94,27);
pic1off.src="enter1.gif";
}

function lightup(imgName)

{
if (document.images)
{
imgOn=eval(imgName + "on.src");
document[imgName].src= imgOn;
}
}

function turnoff(imgName)

{
if (document.images)
{
imgOff=eval(imgName + "off.src");
document[imgName].src= imgOff;
}
}

//-->
</script>

<a href="test.html" onMouseover="lightup('pic1')" onMouseout="turnoff('pic1')"><img src="enter1.gif" name="pic1" width="94" height="27" border="0"></a>
~~~~~~~~~~~~~~~~~~~~~`

good luck.

Ian

------------------
Webmaster A1 JavaScripts
A1 JavaScripts
Head Guide 123Webmaster.com
123Webmaster com

[This message has been edited by Ian (edited 20 April 2000).]

Webmaster A1 JavaScripts
A1 JavaScripts
Web Development - Big Resources Inc
BIG Resources.com

They have: 21 posts

Joined: Mar 2000

Thanks Ian, it works great now.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.