Count Matching Drop-Down Selections in an Adobe Acrobat Form
Question details
Count how many of 15 drop-down fields contain a specific option and display the result in a text field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form has 15 drop-down fields and needs a separate text field to show the count for a selected option.
- Observed behavior
- The result field should update to show the number of drop-down fields whose committed value matches the specified option.
Open the PDF in an Acrobat edition that lets you edit form fields, and check the field names and the option's export value. The example below assumes the fields are named Dropdown1 through Dropdown15.
Add a Custom Calculation Script to the Result Field
Use this method to count an exact value across 15 Acrobat drop-down fields and display the total in a text field.
The script compares each field's value as a string. If an option has an export value, use that value in the comparison rather than assuming the visible label is used.
Open the PDF in Acrobat and select All tools > Prepare a form, or Tools > Prepare Form in older versions.
Open each drop-down field's Properties and check its name and option values. Use Dropdown1 through Dropdown15 for the example, or adjust the script to match your field names.
Add or select the text field that will display the count. Open its Properties, select the Calculate tab, and choose Custom calculation script > Edit.
In the JavaScript editor, enter the following script and replace A with the value to count: var total = 0; for (var i = 1; i <= 15; i++) { if (this.getField("Dropdown" + i).valueAsString == "A") total++; } event.value = total;
For each drop-down field, open Properties > Options and select Commit selected value immediately. Save the PDF, exit form editing, and test several selections.

Work With PDFs and Office Files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with office documents and PDFs. It supports common Microsoft Office formats for easier migration, but it does not replace Acrobat's custom form calculation setup.

Frequently Asked Questions
Why does the count stay at zero even when an option is selected?
Check each drop-down's Properties > Options for its export value. The script must compare against the stored value, which may differ from the visible option label. Also verify that the field names match the script.
How can I make the count update as soon as a selection changes?
In Prepare a form, open each drop-down field's Properties > Options and select Commit selected value immediately. Then test the form outside the editing view.
Can I count a different number of drop-down fields?
Yes. In the custom calculation script, change the loop limit from 15 to the number of consecutively named fields, and make sure the field-name prefix matches your form.
How do I show separate counts for several options?
Create one result text field for each option. In each field's Properties > Calculate > Custom calculation script, use the same loop and replace A with the corresponding option value.




