Select value Property

❮ Select Object

Example

Change the selected option to "banana":

document.getElementById("mySelect").value = "banana";
Try it Yourself »

Description

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


Browser Support

Property
value Yes Yes Yes Yes Yes

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
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.