PDF Editing Issues

How to Create a PDF Form Markup Calculation Script by Price Range

Muhammad TalhaMuhammad Talha Nov 3, 2026 868 views

Question details

The user needs a custom calculation script for a PDF form to dynamically assign a markup multiplier based on a provided price range.

How to Create a PDF Form Markup Calculation Script by Price Range
Product
Adobe Acrobat PDF
Device & OS
not provided
Scenario
Setting up a dynamic PDF document for quoting or invoicing where a specific markup multiplier changes according to the numerical value entered into the 'Price' field.
Observed behavior
The goal is to automatically output a markup value of 1.10, 1.20, or 1.30 depending on whether the input price is <=5, between 5 and 7, or between 7 and 10.
Before you start

Ensure you have a PDF editor that supports JavaScript form logic (like Adobe Acrobat Pro) and verify that a text field named exactly 'Price' already exists in your document.

Solution 1Recommended

Adding a Custom JavaScript Calculation for Markup Ranges

Use the custom calculation script feature in your PDF editor to implement conditional logic that reads the 'Price' field and outputs the corresponding markup multiplier.

Advanced PDF forms utilize JavaScript to handle complex conditional logic. By extracting the value of the 'Price' field, you can set up an if-else statement to determine the correct markup and assign it directly to the markup field.

1
Access Form Properties

Open your PDF in 'Prepare Form' mode. Right-click the specific text field where you want the markup to appear (e.g., the 'Markup' field) and select 'Properties'.

2
Navigate to the Calculate Tab

In the Text Field Properties dialog box, click on the 'Calculate' tab to set up your mathematical logic.

3
Enter the Custom Script

Select the 'Custom calculation script' radio button and click 'Edit'. Paste the following code: var price = Number(this.getField("Price").valueAsString); if (price <= 5) event.value = 1.1; else if (price <= 7) event.value = 1.2; else if (price <= 10) event.value = 1.3;

4
Save and Test

Click 'OK' to close the script editor, then close the Properties window. Enter different numerical values into your 'Price' field to verify that the markup field updates automatically.

Handling Out-of-Range Values: You may want to add a final 'else' condition (e.g., else event.value = 1.4;) to ensure the script handles any price values that exceed 10 or are left completely blank.

Manage and Fill Interactive PDF Forms with WPS Office

WPS Office offers a comprehensive PDF editor that allows you to easily view, manage, and fill interactive PDF forms, ensuring accurate calculations and a smooth document workflow.

  1. 1. Open the PDF: Launch WPS Office and click on the 'PDF' tab to open your interactive document.
  2. 2. Fill the Form Fields: Click into the form fields. WPS PDF will automatically recognize interactive text boxes, including those with built-in calculation scripts.
  3. 3. Save or Export: Once the calculations are complete and the form is filled out, click 'Save' or export the document directly to your device.
Fully compatible with standard PDF forms and interactive fields.Lightweight and fast PDF viewer and editor for seamless multitasking.Easily edit text, images, and fill out complex forms without expensive subscriptions.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF form calculation script not updating automatically?

The calculation order might be incorrect, or the field triggering the calculation isn't set to commit the selected value immediately. Check your form properties under 'Options' and ensure 'Commit selected value immediately' is checked on the input field.

Can I use standard math operators instead of JavaScript in PDF forms?

Yes, for simple mathematical operations like addition, multiplication, or averaging, you can select 'Value is the [sum/product] of the following fields' directly in the Calculate tab without needing to write custom JavaScript.

How do I prevent the script from showing a default value when the Price field is empty?

You can wrap your script in a check that verifies if the field is empty before calculating. For example, add 'if (this.getField("Price").valueAsString === "") { event.value = ""; return; }' at the beginning of your calculation script.