Input Radio value Attribute
Definition and Usage
value
Sets or returns the value of the radio button's value attribute.
For radio buttons, the content of the value attribute does not appear in the user interface. The value attribute is only meaningful when submitting a form. If the radio button is selected when the form is submitted, the name of the radio button and the value of the value attribute are sent together (if the radio button is not selected, no information is sent).
Tip:Define different values for radio buttons in the same group so that (on the server side) the selected option can be identified.
See also:
HTML Reference Manual:HTML <input> value Attribute
Example
Example 1
Get the value of the radio button's value attribute:
var x = document.getElementById("myRadio").value;
Example 2
Change the value of the radio button's value attribute:
document.getElementById("myRadio").value = "newRadioBtnValue";
Example 3
Use radio buttons and text input fields to display the value of the selected radio button:
document.getElementById("result").value = browser;
Syntax
Return value attribute:
radioObject.value
Set value attribute:
radioObject.value = text
Attribute Value
Value | Description |
---|---|
text | Specifies the value associated with the input (this is also the value sent when submitted). |
Technical Details
Return Value: | A string value representing the value of the value attribute of the radio button. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |