How to Use Acrobat JavaScript If Statements for Multiple Drop-Down Values
Question details
The user needs to write an Adobe Acrobat JavaScript form calculation script that checks a drop-down field for multiple specific values and outputs one result if a match is found, or a default result otherwise.
- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up an interactive PDF form where a target text field automatically calculates and populates a number based on a user's selection from a drop-down menu.
- Observed behavior
- The goal is to automatically assign a specific value (e.g., 0.5) to a target field when the drop-down selection is KUR1, KUR2, or KUR3, and assign a default value (e.g., 1.0) for all other selections.
Before creating your script, ensure your PDF editor supports JavaScript form calculations and verify the exact, case-sensitive field names for both your drop-down menu and target text box.
Use the Logical OR (||) Operator in an If Statement
Use a custom calculation script combining multiple conditions into a single 'if' statement using the logical OR operator.
The most straightforward way to evaluate multiple values from a single drop-down menu is to use the logical OR operator (||). This allows the script to trigger the same outcome if any of the specified conditions are met.
Open your PDF form in Edit mode, right-click the target field where the result should appear (e.g., 'Min'), and select 'Properties'.
Navigate to the 'Calculate' tab within the Properties window, select the 'Custom calculation script' option, and click the 'Edit' button.
Type the following script into the editor: if (event.value == "KUR1" || event.value == "KUR2" || event.value == "KUR3") { this.getField("Min").value = 0.5; } else { this.getField("Min").value = 1.0; }
Click 'OK' to save the script, close the properties window, and test your drop-down menu to ensure the target field updates properly.

Use a Switch Statement for Cleaner Code
A switch statement is an alternative approach that is easier to read and maintain when you have a long list of drop-down options.
Edit and Manage PDF Forms Easily with WPS Office
While advanced JavaScript calculations require specialized setups, you can effortlessly view, fill, and edit interactive PDF forms using WPS Office's built-in PDF Editor. It provides a lightweight, highly compatible environment for your document needs.
- 1. Install WPS Office: Download and install the free WPS Office suite on your computer or mobile device.
- 2. Open Your PDF: Launch WPS Office and open your interactive PDF form document.
- 3. Fill the Form: Click on any interactive drop-down menu, text box, or checkbox to easily fill out the required information.
- 4. Save and Export: Save your filled document natively as a PDF or export it to other formats as needed.

Frequently Asked Questions
Why isn't my PDF form calculation updating automatically?
If your field relies on the value of a drop-down menu, the calculation order in your PDF editor might be incorrect. Ensure that the target field is set to calculate only after the drop-down menu's value has been processed.
Can I use regular expressions instead of multiple OR operators?
Yes. If all your target values share a distinct pattern (like starting with 'KUR'), you can use JavaScript regular expressions, such as if (/^KUR[1-3]$/.test(event.value)), which makes the code more concise.
Are JavaScript form calculations supported in all PDF readers?
No. Many web browser-based PDF viewers and basic mobile PDF apps do not support executing complex JavaScript form calculations. For best results, advise users to open the form in a fully-featured PDF program.




