title: how to store radio button value in javascript variable?
body: <p>I have a code like this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function validate(form1) 
  {
    if (document.getElementById('agent').checked)
    {
      alert("agent") // works
      var agent1=document.getElementById('agent').value;
      alert(agent1)  // does not work
    }
    if (document.getElementById('holding').checked)
    {
      var holding=document.getElementById('holding').value;
    }
    if(agent1=="agent" &amp;&amp; holding=="holding")
    {
      alert("hiii") // does not work
    }
  }
  </code></pre>
  
  <p></p>
  
  <p>My form is like this:</p>
  
  <pre><code>&lt;form id="form-validation" method="post" name="form1" onSubmit="return validate(this);"&gt;
  &lt;div class="input-group"&gt;
    &lt;input type="radio" name="booking_type" id="direct" value="direct" onclick="document.getElementById('hidethis').style.display='none';return true;" &gt;&lt;span&gt;Direct&lt;/span&gt;
    &lt;input type="radio" name="booking_type" id="agent" value="agent" onclick="document.getElementById('hidethis').style.display='';return true;" onfocus="document.getElementById('agent').clicked"&gt;&lt;span&gt;Agent&lt;/span&gt; 
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
  &lt;label class="col-md-4 control-label" for="val_username"&gt;Reservation Status&lt;span class="text-danger"&gt;*&lt;/span&gt;&lt;/label&gt;
    &lt;div class="col-md-6"&gt;
      &lt;div class="input-group"&gt;
        &lt;input type="radio" name="reservation_status" value="H" onClick="holdingRadionButtonClicked()" id="holding" checked&gt; Holding 
        &lt;input type="radio" name="reservation_status" value="C" onClick="confirmRadionButtonClicked()" id="confirm"&gt; Confirm
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;input type="submit" class="btn btn-info btn-primary " value="Submit" name="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>What I want is that when I click the submit button the value of the radio button has to be stored in the variable.</p>
  
  <p>When I tried to get the control, that worked but when I tried to get the value, it does not.</p>