Select value Property

Select Object Reference Select Object

Example

Change the selected option to "banana":

document.getElementById("mySelect").value = "banana";

Try it yourself »

Definition and Usage

The value property sets or returns the value of the selected option in a drop-down list.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


Syntax

Return the value property:

selectObject.value

Set the value property:

selectObject.value=value

Property Values

Value Description
value Specifies the value of an <option> element in a drop-down list that should get selected. If the value does not exist, the drop-down list will display an empty option

Technical Details

Return Value: A String, representing the value of the value attribute of an <option> element in the drop-down list. If the drop-down list allows multiple selections, the first selected option is returned. If there is no selected options, nothing is returned.

More Examples

Example

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

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

Try it yourself »

Select Object Reference Select Object

SHARE THIS PAGE

COLOR PICKER

colorpicker





Search w3schools.com:

Translate w3schools.com: