Get the value of the value attribute of a radio button:
The result of x will be:
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.
The value property is supported in all major browsers.
Return the value property:
Set the value property:
Value | Description |
---|---|
text | Specifies the value associated with the input (this is also the value that is sent on submit) |
Return Value: | A String, representing the value of the value attribute of the radio button |
---|
Change the value of the value attribute of a radio button:
Using radio buttons together with a text input field to display the value of the selected radio button:
HTML reference: HTML <input> value attribute