Radio value Property
Radio object
Definition and Usage
The value property sets or returns the value of the value attribute of the radio button.
For a radio button, the content of the value attribute value does not appear in the user interface. The value attribute value is only passed to the server when the form is submitted. If a radio button is selected, its value is passed to the server only when the form is submitted (an unselected button does not pass data to the server).
Syntax
Set the value attribute:
radioObject.value="
value
"
Return the value attribute:
radioObject.value
Browser support





All major browsers support the value property.
Example
Example 1
Display the selected value in the radio button:
<
form
Which color do you prefer?
<br>
<input type="radio" name="colors" id="red" value="red" Red>
<br>
<input type="radio" name="colors" id="blue" value="blue" Blue>
<br>
<input type="radio" name="colors" id="green" value="green" Green form>
<button type="button" onclick="displayResult()">Display the selected value
button
Try it »
Example 2
Display the value of the selected radio button:
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Runoob Tutorial(runoob.com)
title
<
script
function displayResult(browser){ document.getElementById("result").value=browser }
script
head
<
body
<
pSelect your favorite browser:
p
<form>
<input type="radio" name="browser" onclick="displayResult(this.value)" value=">Internet Explorer
"
Internet Explorer
<br>
<input type="radio" name="browser" onclick="displayResult(this.value)" value="Firefox" Firefox>
<br>
<input type="radio" name="browser" onclick="displayResult(this.value)" value="Opera" Opera>
<br>
<input type="radio" name="browser" onclick="displayResult(this.value)" value=">Google Chrome
"
Google Chrome
<br>
<input type="radio" name="browser" onclick="displayResult(this.value)" value="Safari" Safari>
<br>
<br>Your favorite browser is:
<input type="text" id="result" form body html>Try it »
Radio object