How to Clear Related PDF Form Fields When a Dropdown Value is Not Found
Question details
The user needs a method to automatically clear dependent text fields in a PDF form if a manually entered dropdown value is not part of the predefined source data.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Modifying an interactive PDF form where a combo box allows custom user entries, but dependent fields need to reset if the custom entry lacks corresponding data.
- Observed behavior
- Previously populated information remains in the dependent fields when a user inputs a custom department or name that does not exist in the dropdown's source data.
Ensure you have access to a professional PDF editor that supports JavaScript execution and advanced form field property modifications, such as Adobe Acrobat Pro.
Add a Custom Validation Script to the Dropdown Field
Use JavaScript within the dropdown field's properties to check the entered value and clear related fields if it doesn't match predefined arrays.
When you allow users to enter custom text into a combo box, the PDF needs a script to verify if the entered text exists in your data array. If it doesn't, the script must explicitly set the dependent fields to a blank string.
Open your PDF form in your advanced PDF editor (e.g., Adobe Acrobat Pro) and enter 'Prepare Form' mode.
Right-click the dropdown (combo box) field where users enter the department, and select 'Properties'.
Navigate to the 'Validate' tab and choose 'Run custom validation script'.
Click 'Edit' and enter JavaScript that compares the 'event.value' against your predefined department data array.
Add an if/else condition to your script: if a match is found, populate the fields; else, use 'this.getField("TargetFieldName").value = "";' to clear the dependent fields.

Manage and Edit PDF Forms with WPS Office
WPS PDF provides a comprehensive set of tools for creating, editing, and filling interactive PDF forms. It allows you to quickly adjust text fields, checkboxes, and dropdowns to streamline data collection.
- 1. Open Your PDF: Launch WPS Office and open your PDF document.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon menu to reveal form editing tools.
- 3. Select Form Controls: Click on interactive form controls like 'Text Field' or 'Combo Box' to add them to your page.
- 4. Edit Field Properties: Double-click any form field to open its Properties panel and customize the options, appearance, or names.
- 5. Save the Document: Save your PDF to preserve the interactive form elements for your users.

Frequently Asked Questions
Why do old values stay in my PDF form when I change a dropdown?
When dependent fields are populated using a specific dropdown selection, changing the dropdown to a custom or unmatched value won't automatically erase the other fields unless a script explicitly tells the PDF engine to clear them.
Can I allow custom text in a PDF combo box?
Yes. In the combo box properties under the 'Options' tab, you can check 'Allow user to enter custom text.' This turns a strict dropdown list into an editable combo box.
What JavaScript code clears a PDF form field?
You can clear a specific text field by using the code snippet `this.getField("YourFieldName").value = "";` within your PDF's custom calculation, validation, or keystroke scripts.
Does WPS Office support filling out interactive PDF forms?
Yes, WPS Office fully supports reading and filling out interactive PDF forms, including those with dropdowns, text fields, and checkboxes created in other standard PDF editors.




