How to Combine Three PDF Form Fields into One Field
Question details
The user needs a method to merge the data entered in three separate PDF form fields into one single target form field.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or formatting an interactive PDF form where a full name needs to be aggregated automatically from separate First, Middle, and Last name fields.
- Observed behavior
- A calculation or script is required to concatenate the text strings from three source fields into one destination field, while properly handling blank values.
Ensure your PDF editor supports JavaScript for interactive form fields (such as Adobe Acrobat Pro) and that the source fields (e.g., First1, Middle1, Last1) are already created and named exactly as they will appear in your script.
Add a Custom JavaScript Calculation to the Target Field
Use a custom calculation script in the destination field's properties to automatically fetch, format, and combine the values of the source fields.
By using a small JavaScript snippet in the target field, the PDF will automatically read the text typed into the source fields and join them together with spaces. Using the valueAsString property is crucial here, as it ensures that if a user skips a field (like a middle name), it won't break the script or output 'null'.
Open your PDF in Form Preparation mode. Right-click the destination field (e.g., 'Name1') and select 'Properties' from the context menu.
In the Field Properties dialog box, click on the 'Calculate' tab to view the calculation options for this specific field.
Select 'Custom calculation script' and click the 'Edit' button. Paste the following code: var values = []; values.push(this.getField("First1").valueAsString); values.push(this.getField("Middle1").valueAsString); values.push(this.getField("Last1").valueAsString); event.value = values.join(" ");
Click 'OK' to save the script, then close the Properties window. Exit the form editing mode and type test data into the First1, Middle1, and Last1 fields to see them instantly combine in the Name1 field.

Create and Edit Interactive PDF Forms with WPS Office
WPS PDF provides a comprehensive suite of tools for creating, editing, and managing interactive PDF forms. Easily add text fields, checkboxes, and buttons to your documents without the need for expensive, heavy software.
- 1. Open WPS PDF: Download and launch WPS Office, then open your PDF document using the dedicated PDF tab.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal all interactive form creation tools.
- 3. Add Form Fields: Select the 'Text Field' or other control icons to draw and place interactive fields directly onto your document layout.
- 4. Save and Distribute: Save your newly created interactive PDF. The form fields will remain perfectly compatible with any standard PDF reader your recipients use.

Frequently Asked Questions
Why does 'null' appear in my combined field when a source field is left empty?
This usually happens if you use the standard .value property on an empty field. Modifying your script to use .valueAsString instead ensures that empty fields are treated as blank text strings rather than a null object.
Can I combine more than three form fields using this custom script?
Yes. You can combine as many fields as you need by simply adding additional lines of code (e.g., values.push(this.getField("YourFieldName").valueAsString);) for each new source field before the final join command.
Will the combined field update automatically if a user goes back and changes their first name?
Yes, PDF calculation scripts are triggered automatically in real-time whenever the values of the referenced source fields are modified or updated.




