[thelist] Very basic JavaScript question

Shane Miller smiller at callcenters24x7.com
Thu Sep 30 06:33:13 CDT 2004


This change made it work:

function next() {
    if (document.images) {
        start++;
        if (start > 9)
            start = -1;
        else
            document.images['show'].src = arrayOfImages[start];
    }
}

With the only problem being that the Next button must be clicked twice for
the last image; but solving that problem can wait for later. 

I also found another great approach, detailed here:

www.marshall.usc.edu/computing/ PDF_Files/JavaScript/JavaScript-ws3.pdf

Shane Miller
http://www.callcenters24x7.com

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Shane Miller
Sent: Thursday, September 30, 2004 2:52 AM
To: thelist at lists.evolt.org
Subject: [thelist] Very basic JavaScript question

I don't know JavaScript.  The code pasted below is working well, so that
users can click a "next" button that calls the next() function and they
cycle through the images in the array.  What I'd like to do, though, is
"reset" back to the first picture when I've reached the last image in the
array.  I would like to hard code that, with an additional if-then statement
that if the index is four then change the index to zero, but I don't know
the syntax.

 

I'd sure be grateful if anyone could post some helpful suggestions!

 

Thanks,

 

Shane Miller

http://www.callcenters24x7.com

 


<SCRIPT LANGUAGE="JavaScript"><!--
var arrayOfImages = new Object();
 
var index = 0;
 
arrayOfImages[index++] = 'picture1.gif';
arrayOfImages[index++] = 'picture2.gif';
arrayOfImages[index++] = 'picture3.gif';
arrayOfImages[index++] = 'picture4.gif';
arrayOfImages[index++] = 'picture5.gif';
//--></SCRIPT>

 


<SCRIPT LANGUAGE="JavaScript"><!--
var start = 0;
 
function next() {
    if (document.images) {
        start++;
        if (start > index)
            start = index;
        else
            document.images['imageName'].src = arrayOfImages[start];
    }
}
 
//--></SCRIPT>

 

-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 



More information about the thelist mailing list