Other PDF Issues

How to Add One PDF Form Field Value to Another Using a Button

Emma BrownEmma Brown Nov 3, 2026 869 views

Question details

The user wants to configure a PDF form button to automatically add a manually entered numerical value from one form field to the existing value of another target field.

How to Add One Form Field Value to Another Using a Button in a PDF
Product
Adobe Acrobat / PDF
Device & OS
not provided
Scenario
Creating or editing an interactive PDF form where values need to be dynamically calculated and updated via button clicks.
Observed behavior
The goal is to trigger a calculation script upon clicking a button, successfully updating a target form field's value by adding a number from a source field.
Before you start

Ensure your PDF document has interactive form fields enabled and that you have noted the exact, case-sensitive names of both the source and target fields you want to calculate.

Solution 1Recommended

Use a Custom JavaScript Action on the Button

Add a simple JavaScript code to the button's Mouse Up event to dynamically calculate and update the form field values.

This method utilizes Acrobat's built-in JavaScript engine to instantly pull the current value of the target field, add the new input value from the source field, and push the updated sum back into the target field.

1
Access button properties

Open your PDF form in editing mode, right-click the button you wish to configure, and select 'Properties' from the context menu.

2
Set the action trigger

Navigate to the 'Actions' tab. In the 'Select Trigger' dropdown, choose 'Mouse Up'. In the 'Select Action' dropdown, choose 'Run a JavaScript'.

3
Input the JavaScript code

Click the 'Add' button to open the JavaScript Editor. Type or paste the following script: this.getField("Field1").value += Number(this.getField("Field2").valueAsString);

4
Customize field names and save

Replace 'Field1' with the name of your target field and 'Field2' with the name of your source field. Click 'OK' to save the script, then close the properties window and test your button.

Use a Custom JavaScript Action on the Button
JavaScript Case Sensitivity: JavaScript is case-sensitive. Ensure that the field names you type in the script perfectly match the actual names defined in your form's field properties, including capitalization.
Edit and Fill PDF Forms with WPS PDF

Easily Manage Interactive PDF Forms in WPS Office

WPS Office provides a comprehensive, user-friendly PDF editor that allows you to view, fill, edit, and manage interactive PDF forms seamlessly without needing expensive software.

  1. 1. Open WPS Office: Launch the WPS Office application and select the PDF module from the home screen.
  2. 2. Load your PDF form: Click 'Open' and locate the interactive PDF form file on your computer to open it directly within the application.
  3. 3. Interact with fields: Click on the highlighted form fields to input your data, utilize form buttons, and trigger automated calculations.
  4. 4. Save your progress: Once your form is filled, click 'Save' or use 'Export to PDF' to secure your entered data for sharing.
Fully compatible with standard interactive PDF forms and formats.Supports advanced form-filling and calculation features.Highly compatible with standard Adobe PDF and Microsoft Office file types.Lightweight, fast, and runs smoothly on multiple operating systems.
microsoft office alternative - wps office

Frequently Asked Questions

Why is the script not calculating the values correctly?

This usually happens if the field names in your script do not exactly match the actual form field names. Double-check for typos or incorrect casing, as JavaScript is strictly case-sensitive.

Can I modify the script to subtract values instead of adding?

Yes. You can easily modify the script by changing the '+=' operator to '-='. This will subtract the source field's value from the target field's current value.

What happens if the source form field is left blank?

By using the 'Number()' function along with '.valueAsString' in the script, an empty field is safely converted to a zero. This ensures your calculation continues to work without throwing an error.