Stack Exchange
Calculating the Total As per the radio button selected
I am working with html and javascript.
Below s the html code 
       1.&nbsp;&nbsp;&nbsp Gestational age in weeks&nbsp;&nbsp;&nbsp
         <input type="radio" name="Gestational_age" value="0-27"     onclick='Gestational(this);'/>0-27
         <input type="radio" name="Gestational_age" value="28-31" onclick='Gestational(this);'/>28-31
         <input type="radio" name="Gestational_age" value=">32" onclick='Gestational(this);' />32
         <br>

Javscript code is 
 function Gestational(obj)
 {
   var radios = document.getElementsByName('Gestational_age');

   for (var i = 0, length = radios.length; i < 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===">32")   
{
  var temp= parseInt(0); 
}
  document.getElementById("Total").value = parseInt(document.getElementById("Total").value) +    temp;
}
   }
 }

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.
Please help

This works for me, I think your main problem was using a ".value" reference rather than ".innerHTML"...
1.&nbsp;&nbsp;&nbsp Gestational age in weeks&nbsp;&nbsp;&nbsp
     <input type="radio" name="Gestational_age" value="0-27"     onclick='Gestational(this);'/>0-27
     <input type="radio" name="Gestational_age" value="28-31" onclick='Gestational(this);'/>28-31
     <input type="radio" name="Gestational_age" value=">32" onclick='Gestational(this);' />32
     <br>

Note: When a user clicks on a radio-button, it becomes checked, and all other radio-buttons with equal name become unchecked.
 function Gestational(obj){
     var radios = document.getElementsByName('Gestational_age');
     console.log(radios)
     for (var i = 0, length = radios.length; i < 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===">32"){
             var temp= parseInt(0); 
         }
         document.getElementById("Total").innerHTML =      parseInt(document.getElementById("Total").innerHTML) +    temp;
         }
     }
 }


use .innerHTML instead of .value
 document.getElementById("Total").innerHTML = parseInt(document.getElementById("Total").innerHTML) +    temp;

working demo here
