Answered
try67Correct answer
Community Expert
June 13, 2025
Here's the calculation code for the total field for "On":
var total = 0;
for (var i=1; i<=31; i++) {
var fname = "Drop down#"+i;
var f = this.getField(fname);
if (f==null) {
console.println("Error! Can't locate the field: " + fname);
continue;
}
if (f.valueAsString=="On") total++;
}
event.value = total;
You can easily adjust it for the others. Just change the value in quotes in this line:
if (f.valueAsString=="On")
Make sure you fix the errors you have in the other calculation scripts, though!
Also, I would recommend setting the option for all the drop-downs to commit their selected values immediately (under Properties, Options). Otherwise, the calculation will only update once the user exits the drop-down field, instead of when they make a selection in it.
