|CMSC 498P||February 13, 1996|
III.C. The SELECT sub-element
The SELECT element is a sub-element of the FORM element, and will not do much of anything if used outside of the FORM container tag. The SELECT element represents a user selection field (let's the user choose from a list of predetermined values) and always takes the following form:
<FORM ACTION="someURL" METHOD=POST>
<SELECT NAME="somename" [MULTIPLE] [SIZE="xx"]>
<OPTION VALUE="foo1" [SELECTED]>bar1
. . .
The SELECT element (also a container tag) always takes a NAME attribute. The name must be a unique name that will be used to identify it's selected value by the server side script mentioned in the FORM's ACTION attribute. The optional MULTIPLE attribute specifies that the user may select more than one of the listed values. The optional SIZE attribute specifies how many options are to be shown at a given time. Between the SELECT start and end tags come one or more OPTION tags. Each OPTION tag declares a new value that the user may choose from. The OPTION tag usually has a VALUE tag (not required) which declares the value to be sent back to the server if that option was selected. If the VALUE attrib is not used, then the value that follows the '>' will be used instead. Also allowed is the SELECTED attribute which specifies that OPTION to be the default. The result of specifying more than one option as SELECTED is undefined.
Usually, when the SELECT field is not specified to be MULTIPLE, it is rendered as a drop-down list with only one value (the currently selected one) being shown at a time. If the MULTIPLE is used and size is set equal to one (1), the selection field is normally rendered as a drop-down box. However, if MULTIPLE is used and SIZE is greater than or equal to two (2) a selection field of size SIZE is normally shown.
If a MULTIPLE selection is made, two different VALUEs will be sent to the script with the same associated NAME. It is passed back in the following manner:
It is left to you to make your script capable of handling this.
Following are some examples of different SELCTION tags:
<- Back to Index