Skip to main content
Known Participant
January 8, 2025
Question

Summation box from dropdowns

  • January 8, 2025
  • 2 replies
  • 3555 views

I have been using checkboxes and summation boxes from these checkboxes, but it's complicated and slowing down my document for several reasons. I would like to try using summations from dropdowns instead. 

i.e. if "FOC" is selected in a dropdown, this value (1) is added to a summation box at the end of the document so you can see that 'FOC' was selected 30 times, 'LOC' was selected 12 times, etc.

Is this possible please? I have done a search of the forums as I did think I'd posted this already but can't find it anywhere and the other threads I have found don't answer my query.

Thank you very much!

2 replies

PDF Automation Station
Community Expert
Community Expert
January 8, 2025

There must be a reason your form is performing poorly which may not be solved by switching from checkboxes to dropdowns.  This article might help you improve the performance.  To add up specific selections from the dropdowns you would have to loop through the fields.  You should use a numbering system to name them to make this easier.  For example, if you create the first dropdown in a series and name it "Dropdown", then in form editing mode, right-click > Create multiple copies, then enter 25 down and 1 across you will end of with 25 fields named "Dropdown.0" through "Dropdown.24".  In the summary field for "FOC" enter the following custom calculation script:

 

var ttl=0;
for(var i=0;i<25;i++)
{
if(this.getField("Dropdown."+i).value=="FOC")
{ttl++}
}
event.value=ttl;

 

If your fields are not named with a numbering system you would have to create an array of field names and loop through them instead.

Known Participant
January 8, 2025

Thank you for the link. When you say you added the codes to your "import script", is that the script which appears in All Javascript Strings? So you put code 1 at the very beginning of the text in the Javascript Editor window, and codes 2 and 3 at the very end?

PDF Automation Station
Community Expert
Community Expert
January 8, 2025

No.  That is referring to importing field values from a text file.  Separate issue.

Nesa Nurani
Community Expert
Community Expert
January 8, 2025

How many dropdown fields you have, and what are the names?

You want to result show in separate fields for each selection?

Known Participant
January 8, 2025

I have two dropdowns which should be selected:

1 - Chapter

LOC

FOT

SGH

RI

MEL

TS

 

These need to be added up individually.

 

2 - Licence

B1

B2

B1/B2

 

These also need to be added up individually (i.e. B1 total, B2 total, B1/B2 total)

 

At the very end of my document I have a totals page where I want to show:

LOC (total) -  B1 LOC (total) B2 LOC (total) B1/B2 LOC (total)

FOT (total) -  B1 FOT (total) B2 FOT (total) B1/B2 FOT (total)

etc.

PDF Automation Station
Community Expert
Community Expert
January 8, 2025

From your original question:

"so you can see that 'FOC' was selected 30 times, 'LOC' was selected 12 times, etc."

But then here you say you only have 2 dropdowns.  Please clarify.