SELECT


Another way to enter data is through a pop-up box, where you select from a list of choices. The selection method is more complicated than RADIO or CHECKBOX, but it allows more flexibility. Here is the syntax:

<SELECT NAME="variable name" MULTIPLE SIZE="size">
<OPTION> text description
<OPTION SELECTED> text description
<OPTION VALUE="value"> text description
</SELECT>
Where <SELECT> marks the start and </SELECT> marks the end of the specification of the pop-up box.

NAME is the same as NAME found in RADIO and CHECKBOX. It is the name of the variable.

MULTIPLE is an optional attribute which, if included, allows for all options to be displayed. If MULTIPLE is not included, then only one option from the list will appear.

SIZE represents the number of lines that will appear in the pop-up box. The default is one line.

OPTION is required. Each OPTION line is a line in the pop-up box. It is always good to have a "text description". Otherwise, you will have a blank line.

SELECTED means that this particular OPTION wll appear in the pop-up box. This is similar to the CHECKED attribute found in RADIO and CHECKBOX.

VALUE is the value to be assigned to the selected option. If VALUE is not specified, then the "text description" will become the assigned value.


Here is an example:
Please choose an ice cream flavor.
<SELECT NAME="flavor">
<OPTION VALUE="chocolate"> chocolate 
<OPTION SELECTED VALUE="grape"> grape
<OPTION VALUE="lemon"> lemon
<OPTION VALUE="strawberry"> strawberry
<OPTION VALUE="vanilla"> vanilla 
</SELECT>

Generates a pop-up window that looks like this:
Please choose an ice cream flavor.


Note that the options appeared in the same order as in the code.

Are there other ways to input into a form?


[INDEX] [PREVIOUS] [NEXT PAGE] [CHAPTER 9]

Valid HTML 3.2!