X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Input Radio value Property

Input Radio Object Reference Input Radio Object

Example

Get the value of the value attribute of a radio button:

var x = document.getElementById("myRadio").value;

The result of x will be:

red

Try it yourself »


Definition and Usage

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

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


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 Reference Input Radio Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook