Combine Dropdown and Text Field Values in an Acrobat Calculation Script
Question details
Create a PDF form calculation that displays text only when a dropdown selection and a text field value match a required combination.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A form author wants a result field to respond to both a dropdown selection and a value entered in another field.
- Observed behavior
- The result field should display the specified text when both conditions are met and remain blank otherwise.
Open the PDF in Acrobat and use Prepare a form to check the exact names of the dropdown, text field, and result field. Check the dropdown option's export value as well, because it may differ from the displayed label.
Add a custom calculation script to the result field
Use this method to show a result only when both form fields contain the required values.
The example compares the dropdown value with S1418 and the text field value with 7. Replace the field names, comparison values, and result text with those used in your form.
Comparing quoted text such as "study" == "S1418" compares two literal strings, not a field value. Read each field with getField() instead.
In Acrobat, open Prepare a form, then double-click the text field that should display the result.
In the field properties, select Calculate, choose Custom calculation script, and click Edit.
Enter this script, replacing Dropdown1, Text1, and Result text as needed: var selection = this.getField("Dropdown1").valueAsString; var entered = this.getField("Text1").valueAsString; if (selection === "S1418" && entered === "7") { event.value = "Result text"; } else { event.value = ""; }
Close the properties and use Preview in Prepare a form. Select the matching dropdown option and enter 7, then change either value to confirm the result clears.

Work with PDF Forms and Office Files in WPS Office
WPS Office is a free, lightweight alternative for everyday document work, with a familiar interface and support for common Office formats to make moving files easier. Its PDF tools can help you work with forms, but they do not replace Acrobat's custom calculation scripting.

Frequently Asked Questions
Why is my comparison always false?
A comparison such as "study" == "S1418" compares literal strings. Use this.getField("Dropdown1").valueAsString to read the actual field value, and replace Dropdown1 with the exact field name.
Why doesn't the dropdown match its visible label?
The option may have an export value that differs from its displayed label. In Prepare a form, open the dropdown's properties and check its options, then compare against the export value in the script.
How do I make the result blank when either value changes?
In the result field's Calculate tab, set event.value to an empty string in the script's else branch. This clears the result whenever the required combination is not present.
Where do I put the calculation script?
Open Prepare a form, double-click the result field, and select Calculate > Custom calculation script > Edit. The script belongs on the field that displays the result, not on either input field.




