How to Populate a PDF Dropdown Menu from a Multiline Textbox
Question details
Extracting lines of text from a multiline textbox to populate selectable options in a dropdown menu within a PDF form.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Creating interactive PDF forms where a list of items input into a text box needs to dynamically update a dropdown field.
- Observed behavior
- Requires a custom JavaScript solution to capture the multiline string, split it by line breaks, and assign it to the dropdown menu.
Ensure your PDF editor supports JavaScript for forms and that you know the exact field names for both your multiline textbox and the dropdown menu.
Use JavaScript to Capture and Split Text Field Values
Apply a custom JavaScript action to split the multiline text by carriage returns and set them as dropdown items.
To achieve this, you cannot link the fields directly. Instead, you must use a custom JavaScript snippet that extracts the string contents from the multiline textbox, splits the text by carriage return line breaks, and applies them to the dropdown field using the setItems method.
Open your PDF form in edit mode and write down the exact names of your multiline text field (e.g., 'MultilineTextBoxName') and your dropdown field (e.g., 'DropdownFieldName').
Right-click the element that will trigger the script (this can be the multiline textbox itself, or a custom 'Update' button) and select 'Properties'.
Navigate to the 'Actions' tab. Select 'Run a JavaScript' from the 'Select Action' dropdown menu, and click the 'Add' button.
In the JavaScript editor, enter the following code: var names = this.getField("MultilineTextBoxName").valueAsString; this.getField("DropdownFieldName").setItems(names.split("\r"));
Click 'OK' to save the script, close the properties window, and test your form by entering multi-line text and triggering the action to see the dropdown update.

Create and Edit PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to seamlessly create, edit, read, and fill interactive PDF forms on your device.
- 1. Open your PDF file: Launch WPS Office and open your existing PDF document.
- 2. Access form tools: Navigate to the 'Form' or 'Edit' tab in the top ribbon to access the interactive form editing tools.
- 3. Insert and modify fields: Click to insert text fields, dropdown menus, or checkboxes, and double-click them to modify properties.
- 4. Save your document: Click 'Save' to preserve your interactive form fields for easy distribution and filling.

Frequently Asked Questions
Why is the dropdown menu not updating immediately after typing?
The JavaScript action requires an event trigger to run. If the script is attached to the multiline text field, ensure the trigger is set to 'On Blur'. This means the script will execute as soon as you click outside of the text box.
Can I use commas instead of line breaks to separate dropdown items?
Yes. In the JavaScript code, change the split parameter from split("\r") to split(","). This will read a comma-separated list from the text box and populate the dropdown accordingly.
How do I hide the multiline textbox if it's only used by administrators?
Go to the Properties of the multiline text field, select the 'General' tab, and change the Form Field visibility setting from 'Visible' to 'Hidden'. This allows the script to still read the predefined values without showing the box to the end-user.




