Tyipu
05-04-2004, 07:49 PM
I have created a form using mostly radio buttons (only one checkbox exception). I have two groups of radio buttons in the form. I can get the total of both groups separately now I need to make them total at the end. The only reason I need to organize them in two groups is that the value of the second group can not be more than 10. I can get the two group values perfectly now I need to add them up somehow. Unfortunately I can not get any further.
Thanks for help in advance.
Tyip
My script:
<head>
<script>
function getSum(frm){
sum=0;
for(i=0;i<frm.elements.length;i++){
if((frm.elements[i].type=="checkbox" || frm.elements[i].type=="radio") &&
frm.elements[i].checked){
sum+=frm.elements[i].value*1;
}
}
document.getElementById("showSum").innerHTML=" "+sum;
}
function getSum2(frm){
sum2=0;
for(i=0;i<frm.elements.length;i++){
if((frm.elements[i].type=="checkbox" || frm.elements[i].type=="radio") &&
frm.elements[i].checked){
sum2+=frm.elements[i].value*1;
}
}
if (sum2>10){
sum2=10
}
document.getElementById("showSum2").innerHTML=" "+sum2;
}
function getTotal(?){
?
}
</script>
</head>
And the way I call them in the form tag:
Your points for the first section:<div id=showSum> </div>
Your total points for the last section:<div id=showSum2> </div>
:rolleyes:
Thanks for help in advance.
Tyip
My script:
<head>
<script>
function getSum(frm){
sum=0;
for(i=0;i<frm.elements.length;i++){
if((frm.elements[i].type=="checkbox" || frm.elements[i].type=="radio") &&
frm.elements[i].checked){
sum+=frm.elements[i].value*1;
}
}
document.getElementById("showSum").innerHTML=" "+sum;
}
function getSum2(frm){
sum2=0;
for(i=0;i<frm.elements.length;i++){
if((frm.elements[i].type=="checkbox" || frm.elements[i].type=="radio") &&
frm.elements[i].checked){
sum2+=frm.elements[i].value*1;
}
}
if (sum2>10){
sum2=10
}
document.getElementById("showSum2").innerHTML=" "+sum2;
}
function getTotal(?){
?
}
</script>
</head>
And the way I call them in the form tag:
Your points for the first section:<div id=showSum> </div>
Your total points for the last section:<div id=showSum2> </div>
:rolleyes: