Calculate Acrobat PDF Form Prices from Dropdown Selections
Question details
Calculate a price for each PDF form row using a dropdown selection and entered minutes.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- An Acrobat form has up to 15 rows, each with a dropdown, a minutes field, and a calculated price field.
- Observed behavior
- Each row should use the two prices associated with its dropdown selection and charge for every partial 15-minute period as a full unit.
In Acrobat, open the form in Prepare a form and check the field names and dropdown export values. Decide the per-unit price and fixed additional price for each dropdown option.
Add a custom calculation script to each Acrobat price field
Use this method to calculate each row independently and round partial 15-minute periods up.
The example expects dropdown fields named ins1 through ins15, minutes fields named mins1 through mins15, and result fields named v1 through v15. Replace the five option keys and prices with your actual dropdown export values and prices.
The formula multiplies the number of 15-minute units by the selected per-unit price, then adds the selected fixed price. The example prices are illustrative.
In Acrobat, choose All tools > Prepare a form, then open Properties for the v1 result field.
On the Calculate tab, select Custom calculation script and click Edit. Enter this script: var prices = { "Option 1": { i: 10, iother: 5 }, "Option 2": { i: 12, iother: 5 }, "Option 3": { i: 15, iother: 7 }, "Option 4": { i: 18, iother: 7 }, "Option 5": { i: 20, iother: 10 } }; var row = event.target.name.substring(1); var option = String(this.getField("ins" + row).value); var minutes = Number(this.getField("mins" + row).value) || 0; var price = prices[option]; event.value = price ? Math.ceil(Math.max(0, minutes) / 15) * price.i + price.iother : "";
Open the Calculate tab for each result field from v2 through v15 and paste the same script. It uses the result field name to find the matching dropdown and minutes fields.
Close form editing and select each dropdown option. Enter values such as 15 and 16 minutes to confirm they produce one and two billed units, respectively.

Work with PDF files and price tables in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and spreadsheets. Open compatible Office files when moving your price tables to WPS; use Acrobat for the PDF form JavaScript calculation described above.

Frequently Asked Questions
Why use Math.ceil instead of Math.round?
Math.ceil(minutes / 15) rounds any partial 15-minute period up to a full unit. For example, 16 minutes becomes two units, while Math.round could produce a different result.
Where do I find the dropdown export values?
In Acrobat's Prepare a form tool, open the dropdown field's Properties and check its Options tab. Use the values returned by the field as the keys in the prices object.
Why is a calculated price field blank?
Check that the dropdown value matches a key in the prices object and that the row's fields follow the expected naming pattern, such as ins1, mins1, and v1. Also check that the custom script is saved on the result field's Calculate tab.
How can I change the prices for an option?
Open the result field's Properties, go to Calculate, and edit the prices object in the custom script. Change i for the 15-minute unit price and iother for the fixed additional price, then apply the same changes to the other result fields.




