PDF Editing Issues

How to Add Another Field to an Acrobat JavaScript Calculation

Jason MillerJason Miller Nov 3, 2026 868 views

Question details

The user wants to modify an existing PDF form calculation to add the value of an additional field to the result of a multiplication.

How to Add Another Field to an Acrobat JavaScript Calculation
Product
PDF Forms
Device & OS
not provided
Scenario
Editing form field calculation scripts to sum multiple values.
Observed behavior
The user needs the correct JavaScript syntax to append an addition operation to an existing multiplication formula in a PDF.
Before you start

Ensure you know the exact field name of the new field you want to add, as JavaScript in PDF forms is strictly case-sensitive.

Solution 1Recommended

Update the Custom Calculation Script

Use the plus operator and ensure all field values are treated as numbers to prevent string concatenation.

When adding fields in PDF JavaScript, you must wrap your field references in the Number() function. Without it, the plus operator might concatenate the values as text strings (e.g., turning 1 + 2 into 12) instead of performing mathematical addition.

1
Open Field Properties

Right-click the result field where the calculation happens and select 'Properties'.

2
Navigate to the Calculate Tab

Click on the 'Calculate' tab and ensure 'Custom calculation script' is selected.

3
Edit the JavaScript

Click the 'Edit' button and append your new field using this format: + Number(this.getField("YourFieldName").value);

4
Apply the Full Formula

For example, update your script to: event.value = Number(this.getField("Net").value) * Number(this.getField("%broker").value) / 100 + Number(this.getField("Totalexp").value); Make sure to replace 'Totalexp' with your actual field name.

Update the Custom Calculation Script
Syntax check: Always verify that your parentheses are correctly balanced and field names exactly match what is written in your PDF.
Manage PDF Forms Easily

Edit and Fill PDF Forms with WPS Office

WPS Office provides a comprehensive suite of PDF tools, allowing you to view, edit, fill out, and interact with PDF forms effortlessly, ensuring calculations and scripts run smoothly.

  1. 1. Open WPS PDF: Launch WPS Office and open your interactive PDF form.
  2. 2. Access Form Fields: Navigate to the 'Form' tab to interact with or modify form fields.
  3. 3. Fill and Calculate: Enter your values; WPS PDF natively supports automatic calculation scripts embedded in the document.
Supports interactive PDF forms with embedded JavaScript calculationsHighly compatible with standard Adobe Acrobat PDF formatsLightweight, fast, and completely free to downloadCross-platform support for Windows, Mac, and mobile
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF JavaScript adding values as text strings instead of numbers?

If you do not wrap your field values in the Number() function, JavaScript may treat the form inputs as text. This results in string concatenation (e.g., '1' + '2' = '12') instead of mathematical addition.

How do I fix a syntax error in my PDF calculation script?

Double-check that all parentheses are properly closed, semicolons are placed at the end of statements, and the field names inside this.getField("...") match the form field names exactly, including upper and lower cases.

Can I use standard mathematical operators in PDF JavaScript?

Yes, you can use standard operators such as + for addition, - for subtraction, * for multiplication, and / for division within your custom PDF calculation scripts.