PDF Editing Issues

How to Automatically Set PDF Form Prices by Quantity Range

Kushani NimanthikaKushani Nimanthika Oct 28, 2026 869 views

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.

How to Automatically Set PDF Form Prices by Quantity Range
Product
PDF
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.
Before you start

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').

Solution 1Recommended

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.

1
Enter Form Editing Mode

Open your PDF document in your PDF editor and activate the form preparation or editing mode to access your form fields.

2
Access the Price Field Properties

Right-click on the specific field where you want the calculated price to appear and select 'Properties' from the context menu.

3
Navigate to the Calculate Tab

In the Field Properties dialog box, locate and click on the 'Calculate' tab to set up your automated formula.

4
Enter the Custom Script

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.

5
Test the Form Calculation

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.

Add a Custom Calculation Script to the Price Field
Adding More Ranges: You can easily expand this logic for more pricing tiers by adding additional 'else if (qty >= X && qty <= Y)' conditions before the final 'else' statement.
Powerful PDF Form Editor

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. 1. Download and Install: Visit the official WPS Office website to download and install the free software on your device.
  2. 2. Open Your PDF Form: Launch WPS Office, click on 'Open', and select your interactive PDF document from your local files.
  3. 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.
Effortlessly view, fill, and manage interactive PDF forms.Fully compatible with standard PDF formats and Adobe Acrobat documents.Lightweight application with a user-friendly, tabbed interface.Easily convert PDF forms to editable Word or Excel documents.
microsoft office alternative - wps office

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.