Skip to main content
Option object

Creates and initializes a new option element.


The Option object has these types of members:


The Option object has these methods.


Initializes a new option element. This method cannot be called directly. See Option object.


Standards information

There are no standards that apply here.


Use this object to instantiate new option elements before adding them to a select element. You can specify up to four optional arguments:

sTextString that specifies the option text.
sValueString that specifies the option value.
bDefaultSelectedBoolean that indicates whether the option is the default selection.
bSelectedBoolean that indicates whether this option is selected when it is added to the collection.


Numeric values are coerced into string and Boolean equivalents if possible.


The following script creates three new option objects and adds them to a select element. Because of the optional arguments, option "Two" is originally selected but option "Three" gains focus when the reset button is pressed.

<form action="#">
<select id="oSelect"></select>
<button type="reset">Reset to Defaults</button>
<script type="text/javascript">
var sel = document.getElementById('oSelect');
sel.options.add( new Option("One","1") );
sel.options.add( new Option("Two","2",false,true) );
sel.options.add( new Option("Three",3,1,0) );

See also