Copy link to clipboard
Copied
Good day
Can anyone assist on a calculation scrip to count the drop down selection based on following options: "On" Off" "Travel".
I have 31 rows each with the drop down selection options.
At the bottom of my form, I've added a section to provide the user with a count of each.
Tried multiple calculations but wont work. please help!
Thank you!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you so much! It worked like magic!
I really wish there for there was a compendium t of scipt calculations for lamen Adobe Acrobat form creators!
Have a super day!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more