PDF Editing Issues

How to Create a Rate Table with a PDF Form Calculation Script

Olivia MillerOlivia Miller Nov 5, 2026 869 views

Question details

The user needs to automatically calculate a percentage fee in a fillable PDF form based on the amount entered in a different field.

How to Create a Rate Table with a PDF Form Calculation Script
Product
PDF Forms
Device & OS
not provided
Scenario
Creating a dynamic, fillable PDF form that calculates conditional fees or rates based on user input thresholds.
Observed behavior
The form requires a custom JavaScript calculation script to apply different percentage rates dynamically depending on the specified amount thresholds.
Before you start

Ensure your PDF editor supports JavaScript for form fields, and verify the exact, case-sensitive names of the fields you will be referencing in your calculation script.

Solution 1Recommended

Implement Conditional JavaScript for the Form Field

Apply a custom JavaScript calculation to the destination fee field to evaluate the entered amount and output the corresponding percentage rate.

To achieve dynamic percentage calculations based on specific amount tiers, you must use conditional logic (if/else statements) inside a custom calculation script.

This script retrieves the value from the source field, checks which threshold it falls into, and assigns the appropriate rate to the current field.

1
Open field properties

Open the PDF form in your advanced PDF editor, enter form editing mode, right-click the destination fee/rate calculation field, and select 'Properties'.

2
Navigate to the calculate tab

Go to the 'Calculate' tab within the Properties dialog box and select the option for 'Custom calculation script'.

3
Enter the custom script

Click the 'Edit' button and enter the following code, modifying the field name 'Amount' to match your actual source field: var amount = Number(this.getField("Amount").value);

4
Add the conditional logic

Add the if/else statements for your thresholds: if (amount == 0) event.value = 0; else if (amount <= 200) event.value = 0.1; else if (amount <= 400) event.value = 0.25; else event.value = 0.5;

5
Save and test

Click 'OK' to save the script, close the properties window, exit form editing mode, and test your form by entering different values in the amount field.

Implement Conditional JavaScript for the Form Field
Adjusting Script Values: Make sure to adjust the numerical thresholds (e.g., 200, 400) and percentage rates (e.g., 0.1, 0.25) in the script to match the specific rate table required for your form.
Advanced PDF Form Creation

Create and Edit Fillable PDF Forms with WPS Office

WPS PDF provides comprehensive tools to create fillable forms, set up text fields, and configure automated calculations seamlessly. It is an ideal tool for handling dynamic document workflows.

  1. 1. Open the PDF document: Launch WPS Office and open your PDF document. Navigate to the 'Form' tab on the top ribbon.
  2. 2. Insert form fields: Use the 'Text Field' tool to insert your source and destination fields into the document.
  3. 3. Configure field properties: Double-click the destination field to open its Properties and navigate to the calculation settings.
  4. 4. Apply calculation rules: Define your calculation logic or custom scripts to automatically calculate the rates based on user input.
  5. 5. Save and distribute: Save your interactive PDF and distribute it to your users for seamless data collection.
Easily add and edit interactive PDF form fieldsConfigure basic to advanced field calculationsSeamlessly compatible with Adobe Acrobat PDF formsLightweight application that runs smoothly across all major devices
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my PDF form calculation updating automatically?

This usually happens if the form's calculation order is incorrect or if dynamic calculation is turned off in your PDF viewer preferences. Check your form properties to ensure the source field calculates before the output field.

Can I use different field names in the calculation script?

Yes. Replace the "Amount" string in the this.getField("Amount") function with the exact, case-sensitive name of your source field to ensure the script targets the correct data.

Are JavaScript calculations supported on all mobile PDF readers?

No, many default or mobile PDF viewers do not support JavaScript execution for security reasons. Users should open the form in a fully-featured PDF editor like WPS Office or Adobe Acrobat to ensure calculations work properly.

How do I calculate a percentage based on multiple source fields?

You can declare multiple variables in your script for each field, sum them together (e.g., var total = Number(this.getField("Field1").value) + Number(this.getField("Field2").value);), and then base your if/else conditional statements on the resulting total variable.