If we select red, yellow, green and submit the form, we see this:
red orange yellow green blue purple brown black
(Run this example. Download the source.)
The form's action URL was $url/show.html . That means that when we posted the form, it re-invoked the script ($url ), but Vortex started at the function show instead of the default main . Also, the output MIME type will be HTML (.html ), which is the default anyway. With this addition to the Vortex URL syntax, we can control where the script starts. This enables us to neatly split the script into a function which prints the form (main ) and one which services it (show ), without an "if" statement.
The show function displays the colors we selected ($user_colors ) in a simple table with varying background colors. For each color, we need to show a table <TD> . So we use the <LOOP> statement in Vortex. This takes a variable, and executes the statements inside the block (up to </LOOP> ) once for each value of the variable. Inside the loop, the $user_colors variable is "dereferenced": only its currently-iterating value is visible. It is known as a loop variable .
For good measure, we print the form again so we can change our selections. We do this by calling the <main> function directly, which prints the form. Now another feature of <options> comes in handy - when we print the SELECT box, we want to highlight the options we've already selected. The second argument to <options> handles this: it's a list of values to highlight.
With just a few lines of code, we've handled some otherwise tedious tasks: