Associate
- Joined
- 5 Aug 2006
- Posts
- 1,133
- Location
- Kent, UK
hi,
I'm trying to do something that should be simple. I would like 2 images to change with mouseover, but i can't get it to work
. Its slowly driving me crazy. I am a beginner at this so please excuse me if i've done something stupid 
my JS code is:
(i realise these are all referring to the same image, but pic7 and pic8 refer to different images. I don't know how i can label one image several times other than using this method - if someone knows a tidier way i'd love to know
)
In the <body> my JS is:
so in the second table row, I want the mouseover to change both pic8 and pic3, but it just changes whatever is the first 'pic' on the "lightup" function, not both 
According to a google search, my code seems right. What am i doing wrong?
Cheers
I'm trying to do something that should be simple. I would like 2 images to change with mouseover, but i can't get it to work


my JS code is:
Code:
<SCRIPT language="JavaScript">
<!--
if (document.images)
{
pic1on= new Image(30,31);
pic1on.src="../Graphics/buttons/menu_icon.png";
pic1off= new Image(30.31);
pic1off.src="../Graphics/buttons/menu_icon_blank.png";
pic2on= new Image(30,31);
pic2on.src="../Graphics/buttons/menu_icon.png";
pic2off= new Image(30.31);
pic2off.src="../Graphics/buttons/menu_icon_blank.png";
pic3on= new Image(30,31);
pic3on.src="../Graphics/buttons/menu_icon.png";
pic3off= new Image(30.31);
pic3off.src="../Graphics/buttons/menu_icon_blank.png";
.... ETC, UP TO ...
pic8on= new Image(15,10);
pic8on.src="../Graphics/buttons/subMenu2.png";
pic8off= new Image(15.10);
pic8off.src="../Graphics/buttons/subMenu2off.png";
}
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>

In the <body> my JS is:
Code:
within my table:
<tr>
<td class="menuIcon"><a href="sessions.html" onMouseover="lightup('pic3')" onMouseout="turnoff('pic3')"><img src="../Graphics/buttons/menu_icon_blank.png" name="pic3" width="30" height="31"/></a></td>
<td class="menuText"><a href="sessions.html" onMouseover="lightup('pic3')" onMouseout="turnoff('pic3')">Sessions</a></td>
</tr>
<tr>
<td class="submenuIcon"><a href="reiki.html" onMouseover="lightup('pic8','pic3')" onMouseout="turnoff('pic8','pic3')"><img src="../Graphics/buttons/subMenu2off.png" name="pic8" class="submenuIcon"/></a></td>
<td class="submenuText"><a href="reiki.html" onMouseover="lightup('pic3','pic8')" onMouseout="turnoff('pic3','pic8')">Reiki</a></td>
</tr>

According to a google search, my code seems right. What am i doing wrong?
Cheers