Jump to content
Killersites Forums

Duplicating .js slideshow


rande
 Share

Recommended Posts

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>

Link to comment
Share on other sites

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 by rande
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...