By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,678 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,678 IT Pros & Developers. It's quick & easy.

Javascript Image Swap

P: 2
I need help.

I have a little button that says "next" below a big image, lets call it "image1", when I press the button I want to swap the big image to "image2". And then if I press it again I want it to swap to "image3" and the next time to "image4" and so on.

Im not so good at javascripts but I found a script that can make the button swap "image1" to "image2" when I click it, but the problem comes when I want the same button to swap "image2" to "image3" etc...

Does anyone have a tip?
Sep 7 '05 #1
Share this Question
Share on Google+
2 Replies


P: 2
I have a little button that says "next" below a big image, lets call it "image1", when I press the button I want to swap the big image to "image2". And then if I press it again I want it to swap to "image3" and the next time to "image4" and so on.

Im not so good at javascripts but I found a script that can make the button swap "image1" to "image2" when I click it, but the problem comes when I want the same button to swap "image2" to "image3" etc...

Does anyone have a tip?
Sep 8 '05 #2

acoder
Expert Mod 15k+
P: 16,027
I have a little button that says "next" below a big image, lets call it "image1", when I press the button I want to swap the big image to "image2". And then if I press it again I want it to swap to "image3" and the next time to "image4" and so on.

Im not so good at javascripts but I found a script that can make the button swap "image1" to "image2" when I click it, but the problem comes when I want the same button to swap "image2" to "image3" etc...

Does anyone have a tip?
Use an array to store the images and keep an index variable which points to the current image. Each time the next button is clicked, update the index and show the image at the current index.
Oct 1 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.