rande Posted December 14, 2011 Report Share Posted December 14, 2011 Hi, I'm trying to dupe a script. It seemed very simple. I want the same script in two different positions. Can anyone give me an idea? thanks var images = ["images/bull.jpg", "images/polarbear.jpg", "images/sheep.png", "images/snake.jpg", "images/tiger_21.jpg"]; var currentImage = 0; //index into the images array (0 to 4) var timer; function $(id) { return document.getElementById(id); } function previous() { //currentImage = currentImage -1; currentImage--; //shortcut to subtract one //currentImage = currentImage - 1; if (currentImage == -1) { currentImage = 4; }//an asignment $("slide").src = images[currentImage]; clearInterval(timer);//name doesn't matter; timer = setInterval(previous, 3000); //this reps .img; dot. src; what the image points to. } function next() { //currentImage = currentImage + 1; currentImage++; if (currentImage == 5) { currentImage = 0; } //an asignment $("slide").src = images[currentImage]; clearInterval(timer); timer = setInterval(next, 3000); } window.onload = function() { $("previous").onclick = previous;//normally function have (); its a callback $("next").onclick = next; //start the timer timer = setInterval(next, 3000); //timer is called a handle here. }; </script> </head> <body> <div id="1"> <img id="slide" src="images/bull.jpg" width="400" height="300" /> <br/><br/> <input type="button" name="" id="previous" value="Prev" /> <input type="button" name="" id="next" value="Next" /> </div> <div id="1"> <img id="slide" src="images/bull.jpg" width="400" height="300" /> <br/><br/> <input type="button" name="" id="previous" value="Prev" /> <input type="button" name="" id="next" value="Next" /> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted December 14, 2011 Report Share Posted December 14, 2011 What have you currently done, and what issues are you having? Quote Link to comment Share on other sites More sharing options...
rande Posted December 14, 2011 Author Report Share Posted December 14, 2011 (edited) What have you currently done, and what issues are you having? I've tried everything I can think of. I have a script that I'm trying to plug in to work on three boxes, with different groups of images. Only the first was working. I could link to the current image on the others but the script wasn't working. I kept messing with it and for some reason, and I don't how, but the third one started working but not the first, and I can't get it back to the first or figure out why it did that. I just tested and found out that the other image folders were't being accessed by the other two; imagesSlideShow1, imagesSlideShow2, imagesSlideShow3. They all accessed the Show1. I've tried isolating them, but not sure how to get it to work. I'm not sure how to call up or link to a specific area. One thing I tried was making separate .js labeling 1. 2. 3. I lost my image links when I was figuring that out, and can't get back to them so far. thanks for the response, hope you can help I've been trying for hours now. Edited December 14, 2011 by rande 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.
Note: Your post will require moderator approval before it will be visible.