How list box values can be accessed in the form processing
There are times when a text box just wont cut it. Perhaps you want to restrict
the user to a specific set to choice. For example, if you want users to specify
their states of residency, you dont want to use a text box because some
one might misspell a states name or enter 41 as his state of residency.
When you need users to choose a response to a particular set of valid options,
it is best to use a list box.
Of all the
form field type, the list box is the oddball, being the only one than isnt
created via the<INPUT> tag. Rather, the list box uses two tags, the <SELECT>
and the <OPTION> tags. The <SELECT> tag indicates that a list box
will be created, where as each <OPTION> tag represents a unique choice for
the list box.
<SELECT> tag has two properties that we will discuss: the NAME property
and the SIZE PROPERTY. The name property serves the same purpose as with the text
box form field type it uniquely identifies the particular list box. The SIZE property
determines how many list options are shown at one time. The default value for
the SIZE PROPERTY is 1, which means that a list box, by default, will show only
one option at a time. Display a list box with the default SIZE PROPERTY AND A
LIST BOX WITH A SIZE property.
<OPTION> tag has two important properties. The first is the value property,
which uniquely identifies each separate list box option. When the user selects
a list box option and submits the form, the form processing script is passed the
string in the value property of the selected list box item. The value property
does not determine what is displayed in the list box. Examine the code in listing.
This is the code that, when viewed through a browser.
the <OPTION> Tag
3: <FORM METHOD=GET ACTION = /Scripts/Somefile.asp>
This list box has its SIZE Property set to the default
<SELECT NAME = ASPOption>
7: <OPTION VALUE=5> i like
ASP a lot! </OPTION>
8: <OPTION VALUE = 4>asp SURE
IS NEAT. </OPTION>
9: <OPTION VALUE= 3 > its
10: <OPTION VALUE = 2 >ASP is
11: <OPTION VALUE= 1>Ah! </OPTION>
14: This list box has its SIZE property set
16: <SELECT NAME = Experiences SIZE = 5>
<OPTION VALUE = 10 > 10 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 9 > 9 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 8 > 8 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 7 > 7 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 6 > 6 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 5 > 5 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 4 > 4 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 3 > 3 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 2 > 2 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 1 > 1 YEARS OF asp Experience </OPTION>
<OPTION VALUE = 0 > Less than a year of asp Experience </OPTION>
29: </BODY >
to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
: We never rent, trade, or sell my email lists to
We assure that your privacy is respected
.NET Programming Tutorial Homepage