O.K. Ted here is something for you
[html]<html>
<head>
<title>Untitled</title>
<script language="javascript">
var currentImage = 1;
var timer;
image1 = new Image(); //string array declared
image1.src = "image1.jpg"; //declaration of source for array no 1
//images are store in same folder with html document, if in subfolder myimg
//you will change src so image1.src = "myimg/image1.jpg"
image2 = new Image();
image2.src = "image2.jpg";
image3 = new Image();
image3.src = "image3.jpg";
image4 = new Image();
image4.src = "image4.jpg";
image5 = new Image();
image5.src = "image5.jpg";
function ChangeImage()
{
if (currentImage > 5) //check currentImage against no of all images which is 5
{
currentImage = 1;
}
document.pics.src=eval("image"+currentImage+".src") //display appropriate image according to value of currentImage
currentImage++;
timer = setTimeout("ChangeImage()", 1000);
}
function Stop ()
{
currentImage = 1;
document.pics.src=eval("image"+currentImage+".src")
clearTimeout(timer);
}
</script>
</head>
<body>
<div id="div1" style="position: absolute; top: 100px; left: 900px; width:30px;
height: 10px; border: solid;" onMouseOver="ChangeImage()"
onMouseOut="Stop()">
</div>
<img src="image1.jpg" name="pics">
</body>
</html>[/html]
Yesterday I had blackout get mix up some html and C++ stuff :o , but this code above does work on IE6, NN7.2 and MozillaFireFox1.0.4.
As you see I made major changes to your code (also some comments included in code):
- this is based on use of onMouseOver and onMouseOut
- you don't have to send variables to any of the functions
- just have to declare so many string arrays as you need and you have to make change to this if statement "if (currentImage > 5)" if you use different amount of images.
I will be happy to answer any futher questions, if I'm in charge of my mind :cheesy:
Also you should get hold of some new scripting book you coding is little bite out of time (Sorry)