How to Automatically Set PDF Form Prices by Quantity Range
Question details
The user needs to configure a PDF form to automatically calculate and display specific prices when a user inputs a quantity that falls within predefined ranges.

- Product
- Device & OS
- not provided
- Scenario
- Creating interactive PDF order forms, quotes, or invoices that require dynamic, tiered pricing based on volume discounts or quantity brackets.
- Observed behavior
- Prices need to dynamically update in a designated price field based on the conditional logic of the number entered into the quantity field.
Ensure you have a PDF editor installed that supports form creation and JavaScript calculations, and that you have clearly named your form fields (e.g., 'Quantity' and 'Price').
Add a Custom Calculation Script to the Price Field
Use a custom JavaScript calculation within the field properties to evaluate the entered quantity and output the corresponding tier price.
PDF forms can execute JavaScript to perform complex conditional formatting and calculations. By adding an 'if-else' script to the Price field, you can program the document to automatically evaluate the quantity range and apply the correct unit price.
Open your PDF document in your PDF editor and activate the form preparation or editing mode to access your form fields.
Right-click on the specific field where you want the calculated price to appear and select 'Properties' from the context menu.
In the Field Properties dialog box, locate and click on the 'Calculate' tab to set up your automated formula.
Select the 'Custom calculation script' option and click 'Edit'. Paste the following JavaScript code: var qty = Number(this.getField("Field1").valueAsString); if (qty == 0) event.value = ""; else if (qty >= 1 && qty <= 19) event.value = 2.75; else if (qty >= 20 && qty <= 49) event.value = 2.50; else event.value = ""; Replace 'Field1' with the exact name of your quantity input field, and modify the range numbers and prices to fit your specific needs.
Click 'OK' to save the script, then close the Properties window. Exit the form editing mode and type different numbers into the quantity field to ensure the price updates accurately.

Easily Manage Interactive PDF Forms with WPS Office
WPS Office offers a comprehensive PDF toolkit that empowers you to view, fill, edit, and manage interactive PDF documents. Streamline your workflow with a versatile office suite that handles all your document needs in one place.
- 1. Download and Install: Visit the official WPS Office website to download and install the free software on your device.
- 2. Open Your PDF Form: Launch WPS Office, click on 'Open', and select your interactive PDF document from your local files.
- 3. Fill and Manage: Navigate to the 'PDF' tab to fill out form fields, edit content, add signatures, or use advanced PDF management tools seamlessly.

Frequently Asked Questions
Why is my custom calculation script not outputting a price?
This typically occurs if the field name referenced in your script (e.g., 'Field1') does not perfectly match the actual name of your quantity form field. Field names are case-sensitive. Verify the exact name in the field properties and update your script accordingly.
How do I add a price for quantities of 50 or more?
You can add another condition to your script. Before the final 'else' statement, insert a line like: else if (qty >= 50) event.value = 2.00; This will assign a price of 2.00 for any quantity of 50 or above.
Will these automated prices work when sending the PDF to clients?
Yes. As long as your clients open the PDF using a standard PDF reader that supports JavaScript (such as Adobe Acrobat Reader or WPS PDF), the background script will execute and calculate the prices automatically when they enter a quantity.




