Jump to content

[SOLVED] Rollover problems


Yesideez

Recommended Posts

Hi, trying to get a rollover image using Javascript but can't get it to work.

 

http://cheekymonkeys.pictureinthesky.net/equipment.php

 

That's the direct link to the page and the six orange buttons should change to yellow but nothing is happening, not even an error in the status bar.

 

Here's the code for the Javascript:

<script language="JavaScript">
rollImage=new Array()
rollImage[0]=new Image(141,23)
rollImage[0].src="/gfx/btn_cloudsstars.gif"
rollImage[1]=new Image(141,23)
rollImage[1].src="/gfx/btn_cloudsstars_sel.gif"
rollImage[2]=new Image(141,23)
rollImage[2].src="/gfx/btn_pinkfairy.gif"
rollImage[3]=new Image(141,23)
rollImage[3].src="/gfx/btn_pinkfairy_sel.gif"
rollImage[4]=new Image(141,23)
rollImage[4].src="/gfx/btn_obstaclecourse.gif"
rollImage[5]=new Image(141,23)
rollImage[5].src="/gfx/btn_obstaclecourse_sel.gif"
rollImage[6]=new Image(141,23)
rollImage[6].src="/gfx/btn_bouncyslide.gif"
rollImage[7]=new Image(141,23)
rollImage[7].src="/gfx/btn_bouncyslide_sel.gif"
rollImage[8]=new Image(141,23)
rollImage[8].src="/gfx/btn_sumosuits.gif"
rollImage[9]=new Image(141,23)
rollImage[9].src="/gfx/btn_sumosuits_sel.gif"
rollImage[10]=new Image(141,23)
rollImage[10].src="/gfx/btn_availableextras.gif"
rollImage[11]=new Image(141,23)
rollImage[11].src="/gfx/btn_availableextras_sel.gif"

function swapOut(imgName,imgID) {
  document.imgName.src=rollImage[imgID].src;
  alert "out";
  return true;
}

function swapBack(imgName,imgID) {
  document.imgName.src=rollImage[imgID].src;
  alert "back";
  return true;
}
</script>

 

Here's a line of HTML for one of the buttons:

<a href="equipment.php?item=clouds" onmouseover="swapOut('imgClouds',0)" onmouseout="swapBack('imgClouds',0)">
<img src="gfx/btn_cloudsstars.gif" name="imgClouds" alt="Clouds & Stars Castle" width="141" height="23" border="0" />
</a>

 

I've split the HTML onto 3 lines to make it easier to read.

 

I've also added an alert to help debug but I don't even get that.

Link to comment
https://forums.phpfreaks.com/topic/79014-solved-rollover-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.