How to Calculate PDF Form Totals from a Dropdown and Quantity
Question details
The user needs to calculate a total price in a PDF form by multiplying a selected item from a dropdown list by a quantity entered in another field.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF order form or invoice that requires automated pricing calculations based on user selections.
- Observed behavior
- The user needs a method to associate each dropdown item with a specific price and automatically multiply that price by the quantity field to output a total.
Ensure your PDF editor supports interactive form fields and calculation features. Note the exact field names for your dropdown and quantity fields, as these are required to link the math operations.
Method 1: Use Dropdown Export Values (Recommended & Easiest)
Assign the price of each item as its 'Export Value' in the dropdown properties, allowing you to use built-in multiplication calculation tools without writing code.
This method is the simplest way to calculate totals. By making the backend value of the dropdown equal to the item's price, the PDF can easily multiply it by the quantity field natively.
Right-click your Dropdown field and select 'Properties'. Go to the 'Options' tab. As you add each item name (e.g., 'Widget A'), enter its numerical price in the 'Export Value' box (e.g., '10.50') before clicking 'Add'.
Add a standard Text field for the quantity. In its 'Properties', go to the 'Format' tab and set the format category to 'Number' to ensure users enter valid digits.
Create a Text field for the Total. Right-click it, select 'Properties', and navigate to the 'Calculate' tab. Select 'Value is the product (x) of the following fields', click 'Pick...', and check the boxes for both your Dropdown field and your Quantity field.

Method 2: Use a Custom JavaScript Lookup Table
Write a custom calculation script to map dropdown names to prices if you cannot change the dropdown's export values.
Create and Calculate Interactive PDF Forms with WPS Office
WPS Office provides robust PDF editing capabilities, allowing you to quickly build dynamic invoices, configure dropdown export values, and set up automatic calculations without needing complex programming knowledge.
- 1. Open PDF Tools: Launch WPS Office, open your PDF document, and navigate to the 'Form' tab on the top ribbon.
- 2. Add Form Fields: Use the 'Combo Box' tool to add your dropdown list, and use the 'Text Field' tool for your Quantity and Total boxes.
- 3. Set Prices: Double-click the Combo Box to open its Properties, then input your items and assign prices in the Export Value fields.
- 4. Apply Calculations: Double-click the Total field, go to the Calculate tab, and set it to automatically multiply your dropdown and quantity fields.

Frequently Asked Questions
Why is my PDF form calculating a zero or returning an error?
This usually happens if the export values in your dropdown list are set to text instead of numbers, or if the quantity field contains non-numeric characters (like a typed '$'). Ensure all fields used in the calculation are strictly formatted as numbers.
Do I need to know JavaScript to calculate PDF totals?
Not necessarily. If you map your item prices to the dropdown's Export Values, you can use the built-in 'product' calculation option in your PDF editor's field properties to automatically multiply the fields together without writing any code.
Can I format the resulting total to show a dollar sign automatically?
Yes. In the Total field's properties, navigate to the Format tab. Select 'Number' or a specific custom format, and choose your preferred currency symbol and decimal places. The calculation will output as formatted currency.
How do I handle empty quantity fields in the calculation?
If using built-in multiplication, an empty field is usually treated as zero. If you are writing a custom JavaScript calculation, you should add an 'if' condition to check if the quantity field is empty before performing the multiplication to prevent 'NaN' (Not a Number) errors.




