PDA

View Full Version : Javascript loop an array?


grandpafred
October 15th, 2007, 18:58
I think that's what I want? In this thread
http://www.iwdn.net/showthread.php?t=6690 there is some excellent js code for cycling through images... and I've found a number of other js next / previous type scripts on the web.

Now, my question: the person I'm working on this for, would like the next and previous function to continue thru the array instead of stopping when you get to the end of the array. When at the end of the array click the next link would go back to the first image.

I've tried changing the if else statements for the code in the aforementioned thread, but can't come up with the proper code. I need a hint please.
thanks

the_pm
October 15th, 2007, 22:52
I used my original version of this script here - lodgeatcedarrun.com/ - to cycle the pictures in the framed area. I replaced the alerts within the prev() and next() functions with instructions to cycle to the beginning or the end of the array as necessary. Perhaps this will translate well into whichever version you're using!

grandpafred
October 15th, 2007, 23:06
thanks for the info... I'll be able to figure it out now