Input Radio value Property
Example
Get the value of the value attribute of a radio button:
var x = document.getElementById("myRadio").value;
Try it Yourself »
Description
The value property sets or returns the value of the value attribute of the radio button.
For radio buttons, the contents of the value property do not appear in the user interface. The value property only has meaning when submitting a form. If a radio button is in checked state when the form is submitted, the name of the radio button is sent along with the value of the value property (if the radio button is not checked, no information is sent).
Tip: Define different values for radio buttons in the same group, to identify (on the server side) which one was checked.
Browser Support
Property | |||||
---|---|---|---|---|---|
value | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the value property:
radioObject.value
Set the value property:
radioObject.value = text
Property Values
Value | Description |
---|---|
text | Specifies the value associated with the input (this is also the value that is sent on submit) |
Technical Details
Return Value: | A String, representing the value of the value attribute of the radio button |
---|
More Examples
Example
Change the value of the value attribute of a radio button:
document.getElementById("myRadio").value = "newRadioBtnValue";
Try it Yourself »
Example
Using radio buttons together with a text input field to display the value of the selected radio button:
document.getElementById("result").value = browser;
Try it Yourself »
Related Pages
HTML reference: HTML <input> value attribute
❮ Input Radio Object