I have 5 forms. Each form has a set of radio buttons. Yes =1 no =0. At the bottom of these forms it outputs the sum of the selections. I have this all working just fine. However I need an input box that shows below these 5 forms that totals the sum from each of these forms and their functions. A sample of the radio code is:
<input type="radio" name="repeat2" value="1" onclick="DisplaySum5(this.value);"> <label>Yes</label>
<input type="radio" name="repeat2" value="0" onclick="DisplaySum5(this.value);"> <label>No</label>
I also am posting the code I have for the functions. Now I need help getting these total values in the Combined total input
function DisplaySum(sum) {
var val1 = 0;
for (i = 0; i < document.buildForm.build.length; i++) {
if (document.buildForm.build[i].checked == true) {
val1 = document.buildForm.build[i].value;
}
}
var val2 = 0;
for (i = 0; i < document.buildForm.build2.length; i++) {
if (document.buildForm.build2[i].checked == true) {
val2 = document.buildForm.build2[i].value;
}
}
var val3 = 0;
for (i = 0; i < document.buildForm.build3.length; i++) {
if (document.buildForm.build3[i].checked == true) {
val3 = document.buildForm.build3[i].value;
}
}
var val4 = 0;
for (i = 0; i < document.buildForm.build4.length; i++) {
if (document.buildForm.build4[i].checked == true) {
val4 = document.buildForm.build4[i].value;
}
}
var val5 = 0;
for (i = 0; i < document.buildForm.build5.length; i++) {
if (document.buildForm.build5[i].checked == true) {
val5 = document.buildForm.build5[i].value;
}
}
var sum = parseInt(val1) + parseInt(val2) + parseInt(val3) + parseInt(val4) + parseInt(val5);
document.getElementById('totalSum').value = sum;
}
function DisplaySum2(sum) {
var val1 = 0;
for (i = 0; i < document.attractForm.attract.length; i++) {
if (document.attractForm.attract[i].checked == true) {
val1 = document.attractForm.attract[i].value;
}
}
var val2 = 0;
for (i = 0; i < document.attractForm.attract2.length; i++) {
if (document.attractForm.attract2[i].checked == true) {
val2 = document.attractForm.attract2[i].value;
}
}
var val3 = 0;
for (i = 0; i < document.attractForm.attract3.length; i++) {
if (document.attractForm.attract3[i].checked == true) {
val3 = document.attractForm.attract3[i].value;
}
}
var val4 = 0;
for (i = 0; i < document.attractForm.attract4.length; i++) {
if (document.attractForm.attract4[i].checked == true) {
val4 = document.attractForm.attract4[i].value;
}
}
var val5 = 0;
for (i = 0; i < document.attractForm.attract5.length; i++) {
if (document.attractForm.attract5[i].checked == true) {
val5 = document.attractForm.attract5[i].value;
}
}
var sum = parseInt(val1) + parseInt(val2) + parseInt(val3) + parseInt(val4) + parseInt(val5);
document.getElementById('totalSum2').value = sum;
}
function DisplaySum3(sum) {
var val1 = 0;
for (i = 0; i < document.convertForm.convert.length; i++) {
if (document.convertForm.convert[i].checked == true) {
val1 = document.convertForm.convert[i].value;
}
}
var val2 = 0;
for (i = 0; i < document.convertForm.convert2.length; i++) {
if (document.convertForm.convert2[i].checked == true) {
val2 = document.convertForm.convert2[i].value;
}
}
var val3 = 0;
for (i = 0; i < document.convertForm.convert3.length; i++) {
if (document.convertForm.convert3[i].checked == true) {
val3 = document.convertForm.convert3[i].value;
}
}
var val4 = 0;
for (i = 0; i < document.convertForm.convert4.length; i++) {
if (document.convertForm.convert4[i].checked == true) {
val4 = document.convertForm.convert4[i].value;
}
}
var sum = parseInt(val1) + parseInt(val2) + parseInt(val3) + parseInt(val4);
document.getElementById('totalSum3').value = sum;
}
function DisplaySum4(sum) {
var val1 = 0;
for (i = 0; i < document.closeForm.close.length; i++) {
if (document.closeForm.close[i].checked == true) {
val1 = document.closeForm.close[i].value;
}
}
var val2 = 0;
for (i = 0; i < document.closeForm.close2.length; i++) {
if (document.closeForm.close2[i].checked == true) {
val2 = document.closeForm.close2[i].value;
}
}
var val3 = 0;
for (i = 0; i < document.closeForm.close3.length; i++) {
if (document.closeForm.close3[i].checked == true) {
val3 = document.closeForm.close3[i].value;
}
}
var val4 = 0;
for (i = 0; i < document.closeForm.close4.length; i++) {
if (document.closeForm.close4[i].checked == true) {
val4 = document.closeForm.close4[i].value;
}
}
var sum = parseInt(val1) + parseInt(val2) + parseInt(val3) + parseInt(val4);
document.getElementById('totalSum4').value = sum;
}
function DisplaySum5(sum) {
var val1 = 0;
for (i = 0; i < document.repeatForm.repeat.length; i++) {
if (document.repeatForm.repeat[i].checked == true) {
val1 = document.repeatForm.repeat[i].value;
}
}
var val2 = 0;
for (i = 0; i < document.repeatForm.repeat2.length; i++) {
if (document.repeatForm.repeat2[i].checked == true) {
val2 = document.repeatForm.repeat2[i].value;
}
}
var sum = parseInt(val1) + parseInt(val2);
document.getElementById('totalSum5').value = sum;
}