How to Display Multi-Select List Box Values in Another PDF Field
Question details
Automatically capture multiple selections from an interactive PDF list box and display them in a separate text field using JavaScript.

- Product
- Device & OS
- not provided
- Scenario
- Creating interactive PDF forms where data selected in one multi-select list box needs to populate another field dynamically.
- Observed behavior
- The user needs the correct JavaScript snippet and target field properties to display the selected array values as a formatted string in the target text field.
Ensure you are using a PDF editor that supports JavaScript custom calculations for interactive forms (like Adobe Acrobat or WPS PDF Premium) and that you know the exact name of your source List Box field.
Use a Custom Calculation Script to Transfer List Box Selections
Apply a Custom Calculation Script to the target text field to fetch and format the array of selected values from your list box.
When a user selects multiple items in a PDF list box, the values are stored as an array. To display these selections nicely in another text field, you must set the target field to allow multiple lines and use a short JavaScript snippet to join the array elements into a readable list.
Open your PDF form in edit mode and double-click the target text field to open its Properties dialog. Navigate to the 'Options' tab and check the 'Multi-line' box so the transferred values can appear on separate lines.
Switch to the 'Calculate' tab within the same Properties dialog. Select the 'Custom calculation script' option to enable custom scripting for this specific text field.
Click the 'Edit' button next to the custom calculation script option and paste the following code: var f = this.getField("List Box1").value; if (typeof f == "object") event.value = f.join("\n"); else event.value = f;
In the pasted code, replace "List Box1" with the exact name of your source multi-select list box field. It is case-sensitive. Click 'OK' and close the properties window.
Exit form editing mode and select a few items in your list box to verify that they instantly populate in your newly formatted text field.

Edit and Fill Interactive PDF Forms with WPS Office
WPS Office provides a robust PDF editor that allows you to easily view, fill, and interact with complex PDF forms without needing expensive software.
- 1. Download WPS Office: Download and install WPS Office on your device from the official website.
- 2. Open Your Form: Launch WPS PDF and open your interactive PDF form.
- 3. Interact with Fields: Click directly on list boxes, text fields, and check boxes to fill out your form smoothly.
- 4. Save and Export: Once completed, save your document or export it directly to share with others.

Frequently Asked Questions
Why are my list box selections appearing on one continuous line?
If your selections do not break into new lines, verify that the 'Multi-line' option is checked in the target text field's properties. Also, ensure your JavaScript join method uses the correct newline escape character (\n).
Can I display the list box selections as a comma-separated list instead of on new lines?
Yes. In the Custom Calculation Script, simply change the join method from f.join("\n") to f.join(", ") and the values will be separated by commas on a single line. Remember to uncheck the 'Multi-line' property if you do this.
Why is my Custom Calculation Script not updating the text field at all?
This usually happens if the field name referenced in this.getField("Your Field Name") does not perfectly match the actual list box name in the form. PDF form field names are case-sensitive, so check for typos or extra spaces.
Does WPS Office support PDF form viewing and filling?
Yes, WPS PDF supports interacting with standard form fields and many calculation scripts, ensuring high compatibility for viewing and filling interactive PDFs created in programs like Adobe Acrobat.




