[thelist] Re: prev and next
Kim Bonfils
mail at bonfils.com
Mon Jul 9 02:38:16 CDT 2001
Remember that JavaScript arrays are indexed starting with 0. This means
that an array of 5 elements goes from array[0] to array[4]. But:
array.length is still 5. That is, the highest value for an index will be
the length of the array minus one.
So, to start on the first page of your array, you need to set the index
variable (ind) to 0. As it is, you seem to be starting on page two (since
thepages[1] is not the first, but the second element).
Then, to check whether you've reached the end of the array (in the next()
function) you should check whether ind equals the length of the array minus
one.
(I used if(ind<(thepages.length-1) and that seems to work)
I believe the prev() function is working okay, because you check for the
index being zero (that is, whether you've reached the start of the array).
Hope this makes a bit of sense.
Kim Bonfils
http://kim.bonfils.com
More information about the thelist
mailing list