How to Copy Values Between PDF Form Fields Using Acrobat JavaScript
Question details
The user wants to automatically copy inputted information from one editable source field to multiple read-only destination fields within a PDF document using JavaScript.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Recreating an Excel form as a PDF where certain information (such as account IDs, client names, and project dates) needs to instantly populate multiple fields throughout the document when entered once.
- Observed behavior
- Values need to perfectly sync from the editable source field to destination fields without allowing users to accidentally edit the duplicated destination data.
Ensure you are using a premium PDF editor that supports advanced form creation, field properties modification, and custom JavaScript execution.
Use a Custom Calculation Script on the Destination Fields
This method actively pulls the value from your editable source field into your targeted read-only destination fields.
By applying a calculation script to a destination field, it will constantly monitor and update itself to reflect the value of the designated source field.
In your PDF form editing mode, double-click the destination field to open the Text Field Properties dialog box.
Navigate to the 'General' tab and check the 'Read Only' box. This ensures users cannot manually change the duplicated value later.
Go to the 'Calculate' tab, select 'Custom calculation script', and click the 'Edit' button.
Enter the following code, replacing 'account_id' with the exact name of your source field: `event.value = getField("account_id").valueAsString;`
For subsequent destination fields that require the same data, simply give them the exact same name as this first destination field. They will automatically inherit the same properties and values.

Use a Custom Validation Script on the Source Field
This method pushes the value to the destination field only when the source field changes, which can improve document performance.
Easily Fill and Manage PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily view, interact with, and fill complex PDF forms without expensive software subscriptions.
- 1. Open Your Form: Launch WPS Office and open your interactive PDF form document.
- 2. Input Data: Click directly into the highlighted editable fields to enter your information.
- 3. Trigger Calculations: As you navigate through the document, WPS PDF will automatically execute embedded JavaScript calculations and data duplications.
- 4. Save and Export: Click the 'Save' icon to preserve your inputted form data, or export it to share with clients.

Frequently Asked Questions
Why do multiple PDF fields share the same data when I type in one?
In PDF form design, fields that share the exact same name are treated as instances of the same object. They automatically share the same value and properties. This is a deliberate feature used to instantly duplicate data across multiple pages without requiring complex JavaScript.
What is the difference between custom calculation and custom validation scripts in PDFs?
A custom calculation script continuously evaluates and updates a field's value based on other inputs within the document. A custom validation script, on the other hand, runs only when the specific field it is attached to is modified. Using validation scripts for data copying can reduce processing overhead in highly complex forms.
How do I make a PDF form field read-only?
Open the specific field's Properties dialog box, navigate to the 'General' tab, and check the 'Read Only' checkbox. This setting prevents end-users from manually typing into the field while still allowing JavaScript to automatically populate it behind the scenes.




