X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook