I have the found the following code
how does one go about adapting this code in the form of adding buttons to go forwards and backwards in the slideshow.
I have the found the following code
how does one go about adapting this code in the form of adding buttons to go forwards and backwards in the slideshow.
Slide forward:
Make a button with the following onclick event
<button onclick="slideit()">forward</button>
If you don't want the slide to change every two and a halve seconds, just put this //
before the line:
setTimeout("slideit()",2500);
or delete it.
Slide backward:
<button onclick="slideback()">back</button>
function for sliding backward:
var numSlides = ;
function slideback() {
document.images.slide.src = eval("image"+step+".src");
if (step > 1) {
step--;
}
else {
step=numSlides;
}
}
You need to set numSlides
to the number of slides you have.
HTML:
<button onclick="slideback()">back</button>
<button onclick="slideit()">forward</button>
Script:
var numSlides = ;
var autoplay= ;
function slideback() {
document.images.slide.src = eval("image"+step+".src");
if (step > 1) {
step--;
}
else {
step = numSlides;
}
}
function slideit() {
var step=1;
document.images.slide.src = eval("image"+step+".src")
if (step < numSlides) {
step++
}
else {
step = 1
}
if (autoplay == true) {
setTimeout("slideit()",2500)
}
}
Set autoplay to true/false for autoplay, set numSlides to your number of slides