HTML DOM Select objekt

Select object

The Select object represents the HTML <select> element.

Access Select object

You can access the <select> element using getElementById():

var x = document.getElementById("mySelect");

Try it yourself

Tip:You can also access the Select object by iterating over the form's elements collection.

Create Select object

You can create a <select> element using the document.createElement() method:

var x = document.createElement("SELECT");

Try it yourself

Select object collection

Collection Description
options Return a collection of all options in the drop-down list.

Select object properties

Properties Description
autofocus Set or return whether the drop-down list should automatically focus when the page is loaded.
disabled Set or return whether the drop-down list should be disabled.
form Return a reference to the form containing the drop-down list.
length Return the number of <option> elements in the drop-down list.
multiple Set or return whether multiple options can be selected from the drop-down list.
name Set or return the name attribute value of the drop-down list.
selectedIndex Set or return the index of the selected option in the drop-down list.
size Set or return the size attribute value of the drop-down list.
type Return which type of form element the drop-down list is.
value Set or return the value of the selected option in the drop-down list.

Select object methods

Method Description
add() Add an option to the drop-down list.
checkValidity()
remove() Remove an option from the drop-down list.

Standard properties and events

The Select object supports both standardsPropertiesandEvents.

Related pages

HTML tutorial:HTML formular

HTML reference manual:HTML <select> tag