[thelist] Very basic JavaScript question

Phil Turmel philip at turmel.org
Thu Sep 30 06:37:11 CDT 2004


You should also adjust the comparison and drop the "else", 
like this:

     if (start >= index)
         start = 0;
     document.images['imageName'].src = arrayOfImages[start];

HTH,

Phil

Richard Bennett wrote:
> On Thursday 30 September 2004 11:52, Shane Miller wrote:
> 
>>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.
> 
> 
> Hi,
> Just change this:
> 
> 
>>        if (start > index)
>>            start = index;
>>        else
> 
> To:
> 
>>        if (start > index)
>>            start = 0;
>>        else
> 
> 
> Cheers,
> Richard.


More information about the thelist mailing list