Hello,
I’m trying to make a slideshow that automatically plays when the screen is loaded. I also want it to be able to change images by clicking on forward and backward links on the slideshow to change the image. I’ve been able to do one or the other , but when I try to do them both things just dont work right. I think my problem is with the setTimeout() function. heres what ive got
<head>
var image3=new Image()
image3.src=”gallery/3503111448_363c0a2650.jpg” <——-this is just an example of how the images are loaded in. PHP takes care of this, its working fine.
function slideit(){
if (!document.images)
return
document.images.slide.src=eval(“image”+step+”.src”)
}
function stepup() {
if (step<count)
step++
else
step=1;
slideit()
}
function stepdown() {
if (step==1)
step = count
else
step–;
slideit()
}
</head>
<body>
<div id=”displaycase” onmouseover=”showslide()” onmouseout=”hideslide()”>
<img src=”” name=”slide”>
<div style=”height:20px;width:40px;margin-top:-20px;padding-left:5px;visibility:hidden;” id=”slider”>
<a href=”javascript: void(0);” onclick=”stepdown()”><span class=”trans”><strong style=”font-size:24px;”><</strong></span></a>
<a href=”javascript: void(0);” onclick=”stepup()”><span class=”trans”><strong style=”font-size:24px;”>></strong></span></a>
</div>
</div>
<script>
var step=1
var count=(taken care of by php)
function slideitr(){
if (!document.images)
return
document.images.slide.src=eval(“image”+step+”.src”)
if (step<3)
step++
else
step=1
setTimeout(“slideitr()”,4000)
}
slideitr()
</script>
I’ve left out the PHP code that populates the images and the count, they are working fine, its the way everything is working together thats the trouble. When I invoke the stepup() it either skips one and plays or does nothing. the stepdown() seems to work, but after a few clicks back it just stops. I tried fixing the stepup() function by taking out the incrementer within the function, thinking that would stop it from skipping , but it makes the button do nothing instead. any incites?