Copy link to clipboard
Copied
Hello, I am somewhat familiar with javascript but have no idea on how to get it to work properly on an adobe form that I am using. Right now I have a form with dropdowns with selections of "Yes", "No", "N/A" , and I want calculate the total number of each and print the result to a "totals" box at the bottom of the page. I have tried to put the below code into the "Yes" totals box but I dont have any idea on how to implement in addition to not knowing If I wrote it correctly. Here is the code I wrote for calculating "Yes":
var a = 0;
for ( var i=1; i<= 32; i++){
if(this.getField("AnalysisAccess"+i).valueAsString == "Yes")a++;
};
console.printLn(a.value);
If you use script in "Total" field change last line
from: console.printLn(a.value);
to: event.value = a;
Copy link to clipboard
Copied
[Assuming you're using Acrobat Pro DC, moderator moved this from Using the Community (forums) to Acrobat.]
Copy link to clipboard
Copied
If you use script in "Total" field change last line
from: console.printLn(a.value);
to: event.value = a;
Copy link to clipboard
Copied
Thank you, does it need to be wrapped in a function?
Copy link to clipboard
Copied
No.
Copy link to clipboard
Copied
Use
console.println(a);
not
console.printLn(a.value);