HTML and CSS Reference
In-Depth Information
Creating a Selection List
• To create a selection list, add the elements
<select name=” name ”>
<option value=” value1 ”> text1 </option>
<option value=” value2 ”> text2 </option>
...
</select>
to the Web form, where name is the name of the field associated with the selection
list; value1 , value2 , etc. are the possible field values; and text1 , text2 , etc. are the
entries displayed in the selection list.
• To specify the default value, add the following attribute to one of the option
elements:
selected=”selected”
• To set the number of options displayed at one time in the selection list, add the
attribute
size=” value
to the select element, where value is the number of options displayed in the selec-
tion list at any one time.
• To allow users to make multiple selections, add the attribute
multiple=”multiple”
to the select element.
You'll add a selection list to the Red Ball Pizza survey form to record the type of order
placed by the customer, storing the value in the ordertype field. The program that will
analyze these results will use the field values type1, type2, type3 , or type4 , but the
option text in the selection list will read Carry out , Delivery , Dine in , and Take and bake ,
respectively.
To create the selection list:
1. Return to the survey.htm file in your text editor and scroll down to the bottom of
the second field set.
2. Directly before the closing </fieldset> tag, add the following code (see
Figure 6-26):
<label for=”ordertype”>Order type</label>
<select name=”ordertype” id=”ordertype”>
<option value=”type1”>Carry out</option>
<option value=”type2”>Delivery</option>
<option value=”type3”>Dine in</option>
<option value=”type4”>Take and bake</option>
</select>
Search WWH ::




Custom Search