asp.net.ph

Skip Navigation Links

SELECT Element | SELECT Object

Language References


Denotes a selectable list box or drop-down list.HTML 2, 3.2, 4, 4.01, 5

HTML Syntax

Remarks

The SELECT element defines a selection list on an HTML form. Browsers render the element as a list of options from which the user can select an item. SELECT is always used with a set of OPTION elements, that define the selectable options in the list.

When a FORM containing a selection list is submitted for processing, the control name is provided by the SELECT element and the value provided by the selected OPTION element. If the OPTION specifies a value attribute, that value is sent. Otherwise, it is the text that follows the <option> tag. Only the selected option value ( s ) are submitted to the server.

Members

SELECT Members

Example

The following HTML creates a drop-down list box.

<form name="theForm">
<select name="theList">
   <option>Alpha Romeo
 <option>BMW
 <option>Ferrari
 <option>Mercedes-Benz
 <option>Porsche
 <option>Range Rover
</select>
</form>

The next example creates a multi-select list box by setting the SELECT's size and multiple attributes.

<form name="theForm">
<select name="theList" multiple size=3>
   <option>Alpha Romeo
 <option>BMW
 <option>Ferrari
 <option>Mercedes-Benz
 <option>Porsche
 <option>Range Rover
</select>
</form>

Notes on DOM Access

The value of a selected OPTION in a SELECT element can be retrieved with the following notation:

document.formName.selectName.options
 [document.formName.selectName.selectedIndex].value

To retrieve the selected options for a multi-select list box, authors can iterate through the options collection checking for selected set to true.

 Show me 

The following example adds a new option to the end of an existing SELECT list. In ECMA-compatible scripting languages ( JScript™ and Javascript ), the new Option constructor can also be used.

var oOption = document.createElement ( "OPTION" );
oOption.text="Apples";
oOption.value="5";
document.all.oMyList.add ( oOption );
See Also

multiple   selectedIndex   OPTION   selected   defaultSelected   options



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note