View Full Version : slideshow help please?

10-21-2003, 09:13 PM
Making no headway on this.
Have a vicious loop on the last function called previousImage()!
I am so frustrated. The rule is I have to keep everything up to the last function that I added, as is! The only chgs to be made were manual buttons for this slideshow
- had to take this out.

<script language="JavaScript" type="text/javascript"><!--
mySlideShow = setInterval("nextImage()", 2000)

Can anyone assist or point me in the right direction? I am not good at this yet...I only hope one day...

<title>class: Creating Image Objects with a Function Call</title>
<script language="JavaScript" type="text/javascript"><!--
function newImg (sourceURL) {
zImage = new Image()
zImage.src = sourceURL
return zImage

var currentSlide = 0

if (document.images) {
// if images are supported by the browser, create an array
// of images and preload them
slides = new Array()

slides[0] = newImg("images/img0.jpg")
slides[1] = newImg("images/img1.jpg")
slides[2] = newImg("images/img2.jpg")
slides[3] = newImg("images/img3.jpg")
slides[4] = newImg("images/img4.jpg")

function nextImage() {

if(document.images && document.slideshow.complete) {

if (currentSlide == slides.length) {
currentSlide = 0

function previousImage() {

if (document.images && document.slideshow.complete)
(currentSlide == slides.length)

if (currentSlide == 0)

if (currentSlide == -1)

{ document.slideshow.src=slides[currentSlide].src



<form><table align="center" border=2>
<tr><td><img src="images/img0.jpg" name="slideshow"
width=290 height=265 alt="PET Slideshow"></td></tr>

<tr><td align=center>
<input type="button" value="<<< Previous"
<input type="button" value="Next >>>"

Philip M
10-22-2003, 07:43 AM
Looks like a couple of } closing braces are missing.

10-25-2003, 02:04 AM
Thanks Phillip.
You're right! Bad braces will hurt this - that was one of the problems. This worked with the comparison of the slides.length to -1. So I added the repaired function! There was a good bit for me to learn here.
Thanks for your input.

Corrected Previous Image function below:

function previousImage() {
if (document.images && document.slideshow.complete){
if(currentSlide == -1) {
currentSlide = slides.length - 1