HTML DOM Option Object | Option Object | HTML Option Tutorial By WDH

HTML DOM Option Object

Option value Property



Alert the value of the selected option in a drop-down list:

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

Try it yourself »


Definition and Usage

The value property sets or returns the value of the option (the value to be sent to the server when the form is submitted).

Tip: If the value property is not specified for an option element, then the text content will be sent to the server when the container form is submitted.



Return the value property:


Set the value property:


Property Values

Value Description
value The value to be sent to the server

Technical Details

Return Value: A String, representing the value of the value attribute of the option element


More Examples


Change the value of a specific option element:

document.getElementById("myOption").value = "newValue";