HTML and CSS Reference
EXAMPLE 11.23 ( CONTINUED )
<form name="form1" onSubmit="showme(this);" />
Where do you want to go? <br />
<select name="vacation" size=4 multiple>
<input type="submit" />
<input type="reset" />
The function called showme() is defined. It is passed one parameter, a reference to
a form object.
The variable called choices is declared and assigned an empty string.
The for loop is entered. The initial value, i , is set to 0. As long as the value of i is
less than the length of the options array, the body of the loop will be entered; thus,
as long as we haven't looped through all the options in the menu, the loop will be
If the option from the menu was selected, the selected property will evaluate to true .
If an option was selected, the variable, called choices , will be assigned the text val-
ue of the option; perhaps Maui or Bali will be assigned to choices . Each time
through the for loop, if an option is selected, it will be appended to the variable,
resulting in a string that contains all of the selected options.
The alert dialog box will display the string value containing all the options that
The HTML form called form1 starts here.
The HTML select menu called vacation starts here. It will contain four menu op-
tions, and allow multiple selections. See Figure 11.40.