PDF Editing Issues

How to Combine Two Acrobat JavaScript Results in One PDF Text Field

Phi Hung VoPhi Hung Vo Nov 5, 2026 870 views

Question details

The user needs to display the output of two separate JavaScript routines (one combining multiple field values, the other collecting checkbox findings) within a single PDF text field.

How to Combine Two Acrobat JavaScript Results in One PDF Text Field
Product
Adobe Acrobat / PDF
Device & OS
not provided
Scenario
Populating a single PDF text field using multiple JavaScript functions.
Observed behavior
Currently, the two scripts run separately, causing one routine's results to potentially overwrite the other instead of displaying both outputs together.
Before you start

Ensure you have a basic understanding of JavaScript syntax and have access to the form editing mode in your PDF software to modify field calculation scripts.

Solution 1Recommended

Combine Both Routines into a Single Custom Calculation Script

Merge the two JavaScript routines into one script and concatenate their results using a chosen separator to output a single string.

When multiple scripts target the same text field, the last script to execute will typically overwrite previous data. To display both results successfully, you must evaluate both logic paths within a single script and combine their outputs.

1
Open Form Editing Mode

Open your PDF document in form editing mode and right-click the target text field to access its Properties.

2
Access Custom Calculation Script

Navigate to the 'Calculate' tab, select 'Custom calculation script', and click the 'Edit' button to open the JavaScript editor.

3
Merge the Variables

Paste both routines into the editor. Store the result of the first routine (combined text fields) in a variable like `var result1 = ...;` and the second routine (checkbox findings) in `var result2 = ...;`.

4
Concatenate and Assign

Define a separator such as a space or line break. Assign the combined string to the field's value using `event.value = result1 + " \n " + result2;`.

5
Save and Test

Click 'OK' to close the editor, exit form editing mode, and test your document by modifying the source fields to ensure the target field updates correctly.

Combine Both Routines into a Single Custom Calculation Script
Enable Multi-line Support: If you use a line break (\n) as a separator in your script, ensure the 'Multi-line' option is checked in the text field's Options or Properties tab so the text formats correctly.
Powerful PDF Editor

Edit and Manage PDF Forms Easily with WPS Office

WPS Office includes a comprehensive PDF editor that allows you to easily manage form fields, edit text, and handle interactive PDF documents efficiently.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open your interactive PDF document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form editing and management tools.
  3. 3. Edit Field Properties: Double-click any text field to access its properties, adjust calculations, and format the output directly within the WPS PDF interface.
Seamlessly fill, edit, and create interactive PDF forms.High compatibility with standard PDF formats and complex PDF forms.Lightweight application that opens large PDFs quickly.All-in-one suite covering PDF, Word, Excel, and PowerPoint.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my JavaScript only showing the result of the second routine?

When multiple calculation scripts are applied separately to the same field, the final script executed overwrites the results of the previous ones. You must combine both routines into a single script to display both results simultaneously.

How do I add a line break between concatenated JavaScript results?

You can add a line break by concatenating '\n' between your variables in the script (e.g., `result1 + '\n' + result2`). Additionally, ensure that the 'Multi-line' option is enabled in the text field's properties.

Can I use different separators to format the combined text field?

Yes, you can use any string separator when concatenating your results. Common separators include a space (`' '`), a comma (`', '`), or a hyphen (`' - '`). Just add it between your variable names using the `+` operator.