papillonstudios Posted September 2, 2010 Share Posted September 2, 2010 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? Quote Link to comment Share on other sites More sharing options...
Adam Posted September 2, 2010 Share Posted September 2, 2010 Shouldn't there be 3 parameters in that call..? function slideit(action,start,finish){ Quote Link to comment Share on other sites More sharing options...
Omirion Posted September 2, 2010 Share Posted September 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted September 3, 2010 Author Share Posted September 3, 2010 its still not working, and yeah post some more efficient code please Quote Link to comment Share on other sites More sharing options...
Omirion Posted September 3, 2010 Share Posted September 3, 2010 http://javascript.internet.com/miscellaneous/image-slideshow.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.