How to Reset Dependent PDF Drop-Down Fields Using JavaScript
Question details
The user needs to find a way to automatically clear or reset a dependent drop-down field's selection in a PDF form when the main controlling field is changed or hidden.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Editing an interactive PDF form that contains dependent or conditional drop-down lists where options change based on a previous selection.
- Observed behavior
- Dependent drop-down lists retain their previously selected values even after the controlling field changes or the dependent field is hidden, leading to inaccurate form data.
Ensure you have a PDF editor with interactive form editing capabilities and basic JavaScript support enabled before attempting to modify field scripts.
Use a JavaScript Action to Reset the Form Field
Add a simple reset script to the controlling field so that any changes trigger the dependent field to revert to its default neutral state.
Hiding or showing a field in a PDF form only changes its visibility; it does not erase the data stored within it. To ensure old selections are cleared when a parent field is altered, you must explicitly reset the dependent field using JavaScript.
Open your PDF document in an advanced PDF editor like Adobe Acrobat and enter the interactive form editing mode.
Right-click the controlling field (for example, a 'Gender' drop-down) and select 'Properties' from the context menu.
Navigate to the 'Actions' tab, select 'Run a JavaScript' from the 'Select Action' drop-down list, and click the 'Add' button.
In the JavaScript editor window, type the reset command: this.resetForm(["YourDependentFieldName"]); replacing 'YourDependentFieldName' with the actual name of your dependent field (e.g., "SkirtSize"). Click OK to save.
Open the properties of your dependent field, go to the 'Options' tab, and ensure the very first item in the list is a neutral value such as a blank space or the word "Select". This guarantees the field defaults to an empty state when reset.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools that make creating, editing, and managing interactive form fields straightforward and efficient.
- 1. Launch WPS PDF Editor: Open WPS Office, click on the 'PDF' tab, and open the PDF document you wish to edit.
- 2. Access the Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form editing tools.
- 3. Manage Field Properties: Double-click any existing drop-down or text field to open its properties, where you can rename fields, adjust options, and set default values effortlessly.

Frequently Asked Questions
Why does a hidden PDF form field still submit its old value?
Hiding a field only changes its visibility on the document canvas. The underlying data structure remains intact. If a user made a selection before the field was hidden, that selected value remains active and will be submitted unless manually cleared or reset via a script.
How do I make the default drop-down option a blank space?
Open the drop-down field properties and navigate to the Options tab. Type a single space in the 'Item' box (or type "Select...") and click Add. Then, use the 'Up' button to move this new blank item to the very top of your list. This makes it the default selection.
Can I reset multiple PDF drop-down fields at the same time?
Yes, you can reset multiple fields simultaneously by passing multiple field names within the script's brackets, separated by commas. For example: this.resetForm(["Field1", "Field2", "Field3"]);




