custom calculation for only visible fields to calculate?
I have a Adobe acrobat questionaire which has different scores dependant on which of the 6 check boxes is checked I have set each individual score in a hidden text box which is made visible when the corresponding check box is selected. This works fine except I can't get only the visible score to show in a total field. It also calculates the hidden amounts. I have used the custom calculation java script below on the Total field but nothing shows, can anyone help me : (
// Custom calculation script for Total field
// Initialize variable
var sum = 0;
// Add first field value if its corresponding check box is selected
if (getField("Q1 Client 1#0").value !== "Off") {
sum += +getField("Q1 a1").value;
}
// Add second field value if its corresponding check box is selected
if (getField("Q1 Client 1#1").value !== "Off") {
sum += +getField("Q1 b1").value;
}
// Add third field value if its corresponding check box is selected
if (getField("Q1 Client 1#2").value !== "Off") {
sum += +getField("Q1 c1").value;
}
// Add fourth field value if its corresponding check box is selected
if (getField("Q1 Client 1#3").value !== "Off") {
sum += +getField("Q1 d1").value;
}
// Add fifth field value if its corresponding check box is selected
if (getField("Q1 Client 1#4").value !== "Off") {
sum += +getField("Q1 e1").value;
}
// Add sixth field value if its corresponding check box is selected
if (getField("Q1 Client 1#5").value !== "Off") {
sum += +getField("Q1 f1").value;
}
// Set this field value to the sum, or set to blank if zero
if (sum > 0) {
event.value = sum;
} else {
event.value = "";
}
