...

View Full Version : Resolved Problem with roll-over image code



Cha1
09-04-2010, 07:12 AM
Hi, I'm having a problem getting one of my image rollovers to work, what confuses me is that the other image works fine, I'm trying to get this to
work for an assignment

here's the javascript:



rollImage = new Array()

for(i = 0; i < 12; i++){

rollImage[i] = new Image(85,85);
}



rollImage[0].src = "images/narav2.jpg";
rollImage[1].src = "images/narav3.jpg";
rollImage[2].src = "images/sasuke-avatar-118.jpg";
rollImage[3].src = "images/sasuke.jpg";



function swapNar(img){ //this works fine
document.nar11.src = rollImage[img].src;
return true;
}

function returnNar(img){ //this function works fine as well
document.nar11.src = rollImage[img].src;
return true;
}

function swapSas(img){ //this function not working
document.sasim.src = rollImage(img).src;
return true;
}

function returnSas(img){ //this function also not working
document.sasim.src = rollImage(img).src;
return true;
}






Here's the HTML:




<tr>
<td height="60">
<img src="images/narav2.jpg" name="nar11" width="85" height="85" border="0" id="nar11"/>
</td>

<td>

<a href="naruto.html" onMouseover = "swapNar(1)" onMouseout = "returnNar(0)"> Naruto </a>

</td>
</tr>

<!-- When I mouse over the above link the image rolls over as expected,
the bottom link doesn't work as expected and I can't see what I'm
doing wrong -->



<tr>
<td height="60">
<img src="images/sasuke-avatar-118.jpg" name="sasim" width="85" height="85" border="0" id="sasim"/>
</td>

<td>

<a href="sasuke.html" onMouseout= "swapSas(3)" onMouseover= "returnSas(2)"> Sasuke </a>

</td>


</tr>






I can't see what the problem is with the returnSas and swapSas functions,
I'm still a noob at this and would really appreciate some assistance,
thanks in advance

Philip M
09-04-2010, 09:42 AM
document.sasim.src = rollImage(img).src;

should be

document.sasim.src = rollImage[img].src; // square brackets


BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.



All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Cha1
09-04-2010, 10:04 AM
Thanks very much, I don't believe I didn't see that, I have also clicked "thank user for post".

Sorry about the 'thank you in advance' thing, won't do it again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum