PDF Editing Issues

How to Use JavaScript If-Then-Else for Drop-Down Pricing in Adobe Acrobat

Huma Ashraf ChHuma Ashraf Ch Nov 10, 2026 869 views

Question details

The user needs to implement an Acrobat custom calculation script to dynamically update price fields based on a drop-down list selection in an interactive PDF form.

How to Use JavaScript If-Then-Else for Drop-Down Pricing Fields in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating an interactive PDF registration form that dynamically adjusts pricing (e.g., Member vs. Nonmember) based on a user's drop-down selection.
Observed behavior
A JavaScript solution is required to correctly evaluate the drop-down selection and output the corresponding price into the target calculation field.
Before you start

Ensure your PDF form contains the necessary text fields for the calculated price and a drop-down field configured with your required choices (e.g., 'Yes' and 'No').

Solution 1Recommended

Apply Custom Calculation Script using If-Then-Else Statements

Use Adobe Acrobat's custom calculation script functionality to link the drop-down selection to specific pricing values.

By utilizing Acrobat JavaScript, you can evaluate the value of a drop-down field and use an if-then-else logic block to populate a target text field with the appropriate pricing data.

1
Open Field Properties

Right-click the target price field where the final value should appear, select 'Properties', and navigate to the 'Calculate' tab.

2
Enable Custom Calculation

Select the 'Custom calculation script' radio button and click the 'Edit' button to open the JavaScript Editor.

3
Input the JavaScript Code

Enter the script to retrieve the drop-down value and assign the corresponding price. For example: var f = this.getField("myDropdown"); if (f.value == "Yes") { event.value = this.getField("Member Price").value; } else if (f.value == "No") { event.value = this.getField("NonMember Price").value; } else { event.value = ""; }

4
Configure Drop-Down Properties

Go to the properties of your drop-down field ('myDropdown'). In the 'Options' tab, check 'Commit selected value immediately' to ensure the calculation runs instantly when a user makes a selection.

Apply Custom Calculation Script using If-Then-Else Statements
Field Name Consistency: Make sure the field names used in your script exactly match the names of the fields created in your PDF form. JavaScript is case-sensitive.
Powerful PDF Form Management

Easily Handle Interactive PDF Forms with WPS Office

WPS Office provides a comprehensive built-in PDF editor that lets you easily view, fill, edit, and manage interactive PDF forms without the need for complex scripting or expensive software.

  1. 1. Open Your PDF: Launch WPS Office and open your interactive PDF registration form.
  2. 2. Access Form Tools: Navigate to the 'Form' tab to view and interact seamlessly with drop-down menus and calculation text fields.
  3. 3. Fill and Save: Select your choices from the drop-downs, let the form update dynamically, and save your completed document.
Easily fill and manage interactive PDF formsFully compatible with standard PDF and Adobe Acrobat formatsLightweight application with an intuitive user interfaceFree basic PDF editing and viewing features
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my PDF drop-down field updating the price immediately?

This usually happens if the 'Commit selected value immediately' option is not checked in the drop-down field's properties. Without this setting enabled, the calculation script won't trigger until the user clicks outside the drop-down field.

Can I use exact numerical values instead of referencing another field?

Yes, you can assign numbers directly in the script. For example, you can replace `this.getField("Member Price").value` with a static number like `50.00` in your JavaScript.

Where do I add the custom calculation script in Acrobat?

Right-click the target text field where you want the calculated result to appear, select Properties, go to the Calculate tab, choose the 'Custom calculation script' option, and click the Edit button to paste your code.

What happens if I change the name of my drop-down field?

If you rename the drop-down field in your form, you must also update the `this.getField("newName")` reference in your JavaScript, otherwise the calculation will break and return an error.