PDF Editing Issues

How to Add and Save Custom User Input to a PDF Dropdown Using JavaScript

Nimra MalikNimra Malik Nov 24, 2026 869 views

Question details

The user wants to allow users filling out a PDF form to type custom values into a dropdown list and have those values saved dynamically to the list of available options.

How to Add and Save Custom User Input to a PDF Dropdown Using JavaScript
Product
PDF Form Editor
Device & OS
not provided
Scenario
Creating an interactive PDF form where users need the flexibility to add new items to a predefined combo box list.
Observed behavior
By default, the dropdown does not permanently save custom entries. A custom script is needed so that when the combo box accepts user input, it checks if the input is already in the list, and appends it to the selection list if it doesn't exist.
Before you start

Ensure you are using a PDF editor that supports advanced form editing and JavaScript actions, and that your combo box field properties are configured to allow custom user text input.

Solution 1Recommended

Implement an 'On Blur' JavaScript to Add New Dropdown Options

Use a custom JavaScript script triggered when the user leaves the dropdown field to read the input and dynamically update the options array.

To make this work, the combo box must first be allowed to accept custom keystrokes. Then, an 'On Blur' event action will execute the script precisely when the user clicks away from the dropdown after typing.

1
Enable custom text entry

Right-click your dropdown (combo box) field in form editing mode, select Properties, and under the Options tab, check the box for 'Allow user to enter custom text'.

2
Add an action trigger

Navigate to the Actions tab in the Properties window. Select 'On Blur' from the Select Trigger dropdown menu, and choose 'Run a JavaScript' from the Select Action menu. Click 'Add'.

3
Insert the appending JavaScript code

In the JavaScript editor, paste the following code to read current choices, check for duplicates, and append the new value: var theList=[]; for (var i=0; i<event.target.numItems; i++) theList.push(event.target.getItemAt(i)); var found=0; for (var i=0; i<theList.length; i++) { if (theList[i]==event.value) { found++; break; } } if (!found) { theList.push(event.value); event.target.setItems(theList); event.target.value=event.value; }

Implement an 'On Blur' JavaScript to Add New Dropdown Options
Testing the Form: Exit form editing mode and switch back to the Hand/Selection tool. Type a new item into the combo box and click away to test the dynamic update. The new item should now appear in the dropdown choices.
Edit and Create PDF Forms Easily

Create Interactive PDF Forms with WPS Office

Build professional, interactive PDF forms including dropdowns, text boxes, and buttons using WPS PDF. Quickly adjust field properties and design intuitive user interfaces for data collection.

  1. 1. Open your PDF in WPS Office: Launch WPS Office, select the 'PDF' module, and open your form document.
  2. 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to view all interactive field options available for your document.
  3. 3. Insert and configure a Combo Box: Click 'Combo Box' and draw the field on your PDF page. Double-click the field to open its properties, where you can set up predefined list options and modify input settings.
Seamless compatibility with standard PDF interactive formsEasily insert and customize combo boxes, text fields, and check boxesFull support for form property editing and designLightweight PDF editor available on multiple platforms
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my PDF dropdown saving the typed value?

By default, PDF combo boxes only allow users to select from a predefined list. To save custom typed values, you must explicitly check 'Allow user to enter custom text' in the field's properties and attach a custom JavaScript action to append the new value to the field's item array.

How do I test my PDF JavaScript form fields?

To test form fields and JavaScript actions, you must exit form editing mode. Select the Hand tool or enter the document's 'Preview' mode, then interact with the form fields exactly as an end user would.

Can I delete items from a PDF combo box dynamically?

Yes, but this requires additional JavaScript logic. This typically involves adding a secondary element like a button or checkbox that, when activated, triggers a script to locate the current value in the list array and remove it using the JavaScript splice() method.