Option value attribute
Definition and Usage
value
Property to set or return the value of the option (the value sent to the server when the form is submitted).
Tip:If no value is specified for the option element value attributeThen the text content will be sent to the server when the container form is submitted.
See also:
HTML Reference Manual:HTML <option> value egenskab
HTML Reference Manual:HTML <option> tag
Example
Example 1
Prompt the value of the selected option in the dropdown list:
var x = document.getElementById("mySelect").selectedIndex; alert(document.getElementsByTagName("option")[x].value);
Example 2
Change the value of a specific option element:
document.getElementById("myOption").value = "newValue";
Syntax
Return value property:
optionObject.value
Indstil value egenskab:
optionObject.value = value
Egenskabsværdi
Værdi | Beskrivelse |
---|---|
value | Værdien, der skal sendes til serveren. |
Tekniske detaljer
Returværdi: | Strengværdi, der repræsenterer værdien af option-elementets value egenskab. |
---|
Browser understøttelse
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |