Jump to content

slideshow not working


papillonstudios

Recommended Posts

ok i have this code

var step=1
function slideit(action,start,finish){
if(action == 'abort'){ 
        return
    }
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<finish)
step++
else
step=start
//call function "slideit()" every 2.5 seconds
timer = setTimeout("slideit()", 1000);
}

 

I have like 17 images but i onyl want 5 or 6 displaying on each page so i added the "start" and "finish" variables to the slideIt() function.

 

and then call this on an image slideIt(1,6) but it doesnt work.

 

What am i doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/212395-slideshow-not-working/
Share on other sites

well first of all your first variable is action. So need to change the declaration like so.

Function slideit(start,finish,action)

 

Secondly in the recursion.

timer = setTimeout("slideit()", 1000);

 

You're not declaring your variables. It should look like this.

timer = setTimeout("slideit(start,finish)", 1000);

 

So try this.

var step=1
function slideit(start,finish,action){
   if(action == 'abort'){
        return
    }
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<finish){
step++
}
else{
step=start
}
//call function "slideit()" every 2.5 seconds
timer = setTimeout("slideit(start,finish)", 1000);
}

 

In total your code is sorta inefficient. If you'd like me to make a more efficient code for you post.

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.