Copy link to clipboard
Copied
Hi
I am creating a inspection report, with a list of inspection items. At the side of each items, I have a dropdown list of Pass, to be rectified, N.A. At the end of the report, I want to show the total number of "Pass" selected, "to be rectified" and "N.A". I only need to know how many passes are there, how many "to be rectified" are selected and so on. How can I do that?
Copy link to clipboard
Copied
OK, then you can use this code as the custom calculation script of the field that counts the number of "Pass" selections:
var total = 0;
var fields = this.getField("Dropdown3").getArray();
for (var i in fields) {
if (fields[i].valueAsString=="Pass") total++;
}
event.value = total;
Simply adjust the string in the fourth line to re-use it for the other values.
Copy link to clipboard
Copied
Only some basic JavaScript functions works on mobile devices, so this script won't work, you can try "PDF Expert" app by Readdle for iOS it has more support for JavaScript.
Copy link to clipboard
Copied
What are the names of those fields?
Copy link to clipboard
Copied
Pass, Rectified, to be rectified, N.A. In the dropdown list also these 4 items.
Copy link to clipboard
Copied
OK, then you can use this code as the custom calculation script of the field that counts the number of "Pass" selections:
var total = 0;
var fields = this.getField("Dropdown3").getArray();
for (var i in fields) {
if (fields[i].valueAsString=="Pass") total++;
}
event.value = total;
Simply adjust the string in the fourth line to re-use it for the other values.
Copy link to clipboard
Copied
It works now. Thank you so much.
Copy link to clipboard
Copied
Hi @try67 , does the script work on iOS app? It doesn't seem to work when I use it on my mobile app.
Copy link to clipboard
Copied
Only some basic JavaScript functions works on mobile devices, so this script won't work, you can try "PDF Expert" app by Readdle for iOS it has more support for JavaScript.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now