8.6 Variable Values

A variable isn't just one value, but an array of zero or more values. This is because lists of values are ever-present in Web applications: SELECT boxes on forms, result columns from SQL, etc. The implicit array nature of Vortex variables makes it easy to manipulate such lists, as we'll see in our next example:


  <SCRIPT LANGUAGE=vortex>

  <A NAME=main>
    <$colors = red orange yellow green blue purple brown black>
    <FORM METHOD=post ACTION="$url/show.html">
      Pick some colors: <P>
      <SELECT NAME=user_colors MULTIPLE>
        <options $colors $user_colors $colors>
      </SELECT>
      <P> <INPUT TYPE=submit>
    </FORM>
  </A>

  <A NAME=show>
    You picked these colors:
    <TABLE><TR>
      <LOOP $user_colors>
        <TD BGCOLOR=$user_colors> $user_colors </TD>
      </LOOP>
    </TR></TABLE>
    <main>
  </A>

  </SCRIPT>

(Run this example.    Download the source.)

You might wish to open the next page in a new browser window, so that you can easily refer to the script source as we discuss it.

Let's run the script (next page):

Back: Variable Manipulation Next: Variable Values - Continued
Copyright © 2024 Thunderstone Software LLC. All rights reserved.