Nearly the same code...
Code:
function respuestas1() {
var radios=document.getElementsByTagName("input");
var sum = 0;
for (var i=0; i<radios.length; i++) {
if ((radios[i].type=="radio") && (radios[i].checked)) {
sum += Number(radios[i].value); // assumes numbers are in radio button values
}
}
var average = sum / (radios.length+1); // assumes length value is NOT zero
alert('Sum is: '+sum+'\nAverage: '+average);
return sum;
}
If you need only the averages of the buttons checked, that could be done as well.
Give it a shot yourself if you want to learn.
If not, then just post "I give up!"
Major problem with averages of radio buttons is that only ONE button can be checked in a group.
You would need to change to checkboxes if you want an average of more than one button.