In the for statement, the first expression (i=0) is the initial condition. The next expression (i<=10) is the condition. If it evaluates to true, the statements inside the loop execute. Otherwise, the loop is terminated and the program advances to the first line after the loop's closing bracket. The final expression (i++) is the increment expression. Here, the program adds 1 to i each time through the loop.
This is a good way to generate a menu. To implement Next/Prev buttons like the reader wants, you would need to write a routine that checks the current HTML filename and adds (or subtracts) 1 from it. These buttons are implemented in the sample file. Here's the code that does the job:
These routines show how to do the numeric/string manipulation, but the functionality is fairly minimal. Improvements might include disabling/enabling the buttons if the next (or previous) file in sequence were out of bounds, moving the buttons to a separate frame so you didn't have to duplicate the code, and reassembling the entire URL, not just the path.
[Jump to Part 3]
Web Developer® Site Feedback
Copyright © 1999-2001
All rights reserved.