HTML DOM Input Radio value Property

The HTML DOM Input radio value property is associated with the input element having type=”radio” and the value attribute. It is used to return the value of radio button value attribute or to set it.

The value property for radio button doesn’t affect the user interface of the website as the content is simply not displayed. However it can be used to distinguish between several buttons of the same group when the form is submitted.


Following is the syntax for −

Set the value property −

radioObject.value = text;

Here, text is used for specifying the value for the radio button.


Let us look at an example for the input radio value property −

 Live Demo

<!DOCTYPE html>
<h1>Input radio Value property</h1>
<input type="radio" name="fruits" id="BTN1" value="Mango" >Mango
<p>Get the above element value by clicking the below button</p>
<button type=”button” onclick="getValue()">Get Value</button>
<p id="Sample"></p>
   function getValue() {
      var t = document.getElementById("BTN1").value;
      document.getElementById("Sample").innerHTML = "The value for the radio button is : "+t;


This will produce the following output −

On clicking the “Get Value” button −

In the above example −

We have first created an input element inside a form with type=”radio”, name=”fruits”, id=”BTN1” and value “Mango” −

<input type="radio" name="fruits" id=”BTN1" value=”mango>Mango

We then created a “GET Type” button that will execute the radioType() method on being clicked by the user −

<button type=”button” onclick="radioType()">GET Type</button>

The getValue() method gets the input element using the getElementById() method and assigns its “value” attribute value to variable t. It will return an empty sting if the value attribute has not been specified for the radio button.This variable is then displayed in the paragraph with id “Sample” using its innerHTML property −

function getValue() {
   var t = document.getElementById("PASS1").value;
   document.getElementById("Sample").innerHTML = "The value for the input field is : "+t;