Copy link to clipboard
Copied
Hi Acrobat Community... I am developing a project criteria form that will need to calculate the choices made to provide a project assessment. There are three choices per line. If I calculate using 'Value is the sum (+)' it works—if there is only one choice, but since there are three, I need to calculate them individually. And when I do this for each choice's summary text frame, I get a combined calculation (see attachment). If there are 3 E's, that number needs to be shown.
I think that I will need a 'Simplified field notation' script to help, but I don't know how to create scripts. I did see this post, but I don't know if it will work or how to modify it to fit my needs.
Attached is a screenshot to give context. Each category line radio buttons have the same name. Line one's name is "1 History" line two is "1 Problems", etc. and the user can select either E, A, or N. In the end, there will be 9 different categories, but for now, I'm just testing one to see if doable to do the calculations.
I hope that I am cleary, but if not, please ask questions if you need further clarity. Thanks in advance!!
Copy link to clipboard
Copied
Use this as custom calculation script in one of the text fields:
var fields = ["1 History", "1 Problems"];// add all radio button field names here
var e = 0, a = 0, n = 0;
for ( var i in fields){
if(this.getField(fields[i]).valueAsString === "Choice1")e++;
else if(this.getField(fields[i]).valueAsString === "Choice2")a++;
else if(this.getField(fields[i]).valueAsString === "Choice3")n++;}
this.getField("E Total").value = e;
this.getField("A Total").value = a;
this.getField("N Total").value = n;
Copy link to clipboard
Copied
Use this as custom calculation script in one of the text fields:
var fields = ["1 History", "1 Problems"];// add all radio button field names here
var e = 0, a = 0, n = 0;
for ( var i in fields){
if(this.getField(fields[i]).valueAsString === "Choice1")e++;
else if(this.getField(fields[i]).valueAsString === "Choice2")a++;
else if(this.getField(fields[i]).valueAsString === "Choice3")n++;}
this.getField("E Total").value = e;
this.getField("A Total").value = a;
this.getField("N Total").value = n;
Copy link to clipboard
Copied
Thank you... I'll take a look and see if this works. Clarity question: Since I need to calculate all the E's, A's, and N's individually, would I need to add this same script for all 3 text frames? So, in the example screenshot that was provided earlier, in each place that the number 11 is showing, they are 3 different text frames with the same calculated property info value. But I'm sure I need to provide different script info to make them total correctly. Thanks
Copy link to clipboard
Copied
No, just put script in one field (any text field is fine).
Copy link to clipboard
Copied
Thanks... forgive me, but I'm still not understanding. See the next round of screenshots to be sure I'm clear. How can I achieve a total for each if I only place the script in one text frame? Also, when you speak of "field" is that changing the Choice 1 to E and Choice2 to N, etc.?
Copy link to clipboard
Copied
Leave choices as 'Choice1', 'Choice2' and 'Choice3'.
Script will put totals in all 3 fields.
In the script, you didn't change field names to your actual names.
Field name is not "E" your actual name is "E Total", I updated script so it includes correct field names, use updated script or change field names manually.
Copy link to clipboard
Copied
Thanks, Nesa... I inserted the new script but it still doesn't work. I was going to upload the actual PDF, but I cannot. When I click any of the buttons, no total amount appears.
Copy link to clipboard
Copied
Thank you again, Nesa!! I have completed this project with all "fields" added and the Total calculations' text frames are displaying correctly. Hopefully, I'll be able to use this on other similar projects.
Copy link to clipboard
Copied
Do you mean that you want to count the number of times "E" was selected, for example?
Copy link to clipboard
Copied
Correct. Once that particular project assessment is completed (all 9 categories), they would like to see the total of E's (excellent), A's (average), etc. it has received. Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now