How to Auto-Populate a PDF Field and Allow Manual Editing
Question details
The user wants to automatically populate a PDF form field with data from three other fields while retaining the ability for users to manually edit the resulting value.

- Product
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where a specific field combines data from multiple source fields but needs to remain editable for user corrections.
- Observed behavior
- When using a standard calculation script, the populated field resets and overwrites any manual edits whenever the user clicks away or leaves the field.
Ensure you have a PDF editor that supports form creation and custom JavaScript actions, and take note of the exact names of the form fields you want to combine.
Use a Button Script to Populate the Field
By assigning a JavaScript action to a button instead of using a calculation script, you can populate the field on demand, which prevents the form from continuously overwriting manual edits.
A standard calculation script runs automatically every time the PDF form updates, causing any manual changes to be instantly overwritten by the script's output. Tying the script to a button's 'Mouse Up' event ensures the data is only populated when the user intentionally clicks the button.
Open your PDF form editor, navigate to the form creation tools, and insert a new Button field into your document.
Right-click the newly created button, select 'Properties', and navigate to the 'Actions' tab.
In the Actions tab, set the 'Select Trigger' option to 'Mouse Up' and the 'Select Action' option to 'Run a JavaScript', then click 'Add'.
In the JavaScript editor, input the concatenation script. For example: this.getField("Field4").value = this.getField("Field1").valueAsString + " " + this.getField("Field2").valueAsString + " " + this.getField("Field3").valueAsString;
Save your changes and switch to the hand/preview tool. Click the button to populate the target field, then click inside the field to manually edit the text and verify it does not reset.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides powerful PDF editing capabilities, making it easy to design interactive forms, insert text fields, add action buttons, and customize PDF documents for professional use.
- 1. Open WPS Office: Launch WPS Office and navigate to the PDF tab to open your document.
- 2. Access Form Tools: Click on the 'Form' tab in the top ribbon to access tools for adding text fields, buttons, and other interactive elements.
- 3. Customize and Save: Configure your field properties, adjust the layout, and save your interactive PDF document securely.

Frequently Asked Questions
Why does my calculated PDF field reset when I click away?
If a field uses a built-in calculation script, the PDF viewer automatically recalculates the value whenever the form updates or loses focus. This continuous recalculation overwrites any manual input.
Can I use this script to combine text and numbers?
Yes. By using the '.valueAsString' property in your JavaScript, both text and numerical values from the source fields are treated as strings and can be concatenated without calculation errors.
Do I have to use a button to trigger the script?
While a button is the most user-friendly and reliable way to let the user decide when to populate the field, you could alternatively tie the script to a checkbox or another specific event that does not trigger continuously.




