How to Add One PDF Form Field Value to Another Using a Button
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.

- 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.
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.
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.
Open your PDF form in editing mode, right-click the button you wish to configure, and select 'Properties' from the context menu.
Navigate to the 'Actions' tab. In the 'Select Trigger' dropdown, choose 'Mouse Up'. In the 'Select Action' dropdown, choose 'Run a JavaScript'.
Click the 'Add' button to open the JavaScript Editor. Type or paste the following script: this.getField("Field1").value += Number(this.getField("Field2").valueAsString);
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.

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. Open WPS Office: Launch the WPS Office application and select the PDF module from the home screen.
- 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. Interact with fields: Click on the highlighted form fields to input your data, utilize form buttons, and trigger automated calculations.
- 4. Save your progress: Once your form is filled, click 'Save' or use 'Export to PDF' to secure your entered data for sharing.

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.




