JavaScript Forum JS Made Easy: Free JavaScripts Tutorials Example Code
About This Product
FontsMadeEasy.com
 
The Business Internet
Find it on This page:
 
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet

     
Jsmadeeasy Forums Home   Search   Login   Register   Member List  
JS Made Easy  > JavaScript programming  > Looping in an array question...  
 
Display using:  
Previous Thread :: Next Thread 
 Author Thread: Looping in an array question...
jrutten is not online. Last active: 6/4/2006 3:11:58 PM jrutten
Top 100 Poster
Joined: 12 Apr 2005
Total Posts: 2
 
Looping in an array question...
Posted: 04 Jun 2006 09:37 AM
So I'm using the script below, and I like to modify it to "wraparound" so it is a continual loop as the user clicks - any ideas? Thanks in advance!


var i = 1
images = new Array
images[1] = "YOUR FIRST IMAGE"
images[2] = "YOUR IMAGE"
images[3] = "YOUR IMAGE"
images[4] = "YOUR IMAGE"
images[5] = "YOUR IMAGE"

function previmg(){
if (i != 1){
document.image1.src = images[i-1]
i--
}
}

function nextimg(){
if (i != 5){
document.image1.src = images[i+1]
i++
}
}
Previous Thread :: Next Thread 
Page 1 of 1
 
Jsmadeeasy.com  > JS Made Easy  > JavaScript programming  > Looping in an array question...