title: Calculating the Total As per the radio button selected
body: <p>I am working with html and javascript.</p>
  
  <p>Below s the html code </p>
  
  <pre><code>       1.&amp;nbsp;&amp;nbsp;&amp;nbsp Gestational age in weeks&amp;nbsp;&amp;nbsp;&amp;nbsp
           &lt;input type="radio" name="Gestational_age" value="0-27"     onclick='Gestational(this);'/&gt;0-27
           &lt;input type="radio" name="Gestational_age" value="28-31" onclick='Gestational(this);'/&gt;28-31
           &lt;input type="radio" name="Gestational_age" value="&gt;32" onclick='Gestational(this);' /&gt;32
           &lt;br&gt;
  </code></pre>
  
  <p>Javscript code is </p>
  
  <pre><code> function Gestational(obj)
   {
     var radios = document.getElementsByName('Gestational_age');
  
     for (var i = 0, length = radios.length; i &lt; length; i++) {
  if (radios[i].checked) {
      if(radios[i].value==="0-27")
     {
     var temp = parseInt(9);
  }
  else if(radios[i].value==="28-31")
      {
        var temp= parseInt(8);
      }
  else if(radios[i].value==="&gt;32")   
  {
    var temp= parseInt(0); 
  }
    document.getElementById("Total").value = parseInt(document.getElementById("Total").value) +    temp;
  }
     }
   }
  </code></pre>
  
  <p>I need "TOtal" field to change as per the radio button value selected and I am using "+" plus because I have other radio button Questions which I need to add and atlast print the total.As of now its adding values within the same radio button set ,but i need the "Total" value to change as per the radio button selected and then add new value and subtract previous value.</p>
  
  <p>Please help</p>