How to Clear a PDF Drop-Down Field on Mouse Exit Using JavaScript
Question details
The user needs to configure a PDF drop-down field so that its displayed value clears automatically after an option is selected or when the mouse exits the field.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form where a drop-down list displays explanatory text or colors during interaction but needs to reset to a blank visual state afterward.
- Observed behavior
- By default, the drop-down retains the selected value's text on screen, requiring a custom script to forcefully clear the visible field display while optionally keeping the data for background calculations.
Ensure you are using a PDF editor that supports form field properties and JavaScript execution. Always test custom scripts on a backup copy of your PDF document to avoid accidental data loss.
Use a Custom Format Script to Clear the Display
Apply a simple JavaScript line within the field's formatting properties to automatically set the visible value to a blank string after a selection is made.
This approach uses the built-in custom format script feature. When the form evaluates the field after an interaction, the script forces the display to appear empty.
If the actual selected value is required for other mathematical calculations or data submission, you must write additional code to pass the selected value into a separate, hidden text field before this clearing action occurs.
Open your PDF document in your advanced PDF editor and enter the 'Prepare Form' or 'Form Editing' mode.
Right-click the specific drop-down field you want to modify and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Format' tab. From the 'Select format category' drop-down list, choose 'Custom'.
In the 'Custom Format Script' window, type the following code: event.value = "";
Click 'OK' or 'Close' to save the properties. Exit form editing mode and test the drop-down to ensure it clears after making a selection.

Trigger an Event Script on Mouse Exit
Attach an action script specifically to the 'On Blur' or 'Mouse Exit' event of the drop-down field to clear the display only when the user navigates away.
Create and Manage Interactive PDF Forms with WPS Office
WPS Office PDF provides a robust set of form editing tools, allowing you to easily insert, customize, and manage drop-down lists, text fields, and interactive elements without relying on complex coding.
- 1. Open Your PDF: Launch WPS Office and open the PDF document where you want to add or modify form fields.
- 2. Access the Form Tab: Navigate to the 'Form' tab located on the top ribbon to reveal the interactive form toolkit.
- 3. Add or Edit Drop-Downs: Click the 'Combo Box' or 'Drop-down' icon to draw a new field, or double-click an existing field to access its settings.
- 4. Customize Field Properties: Use the properties panel to add list items, configure export values, and adjust appearance settings before saving the file.

Frequently Asked Questions
Why does a PDF drop-down field keep the selected value visible by default?
By default, interactive PDF forms are designed to display the user's choice so that the filled information can be reviewed or printed. Overriding this behavior requires custom formatting or JavaScript.
Will clearing the visual field delete the selected data permanently?
Yes, if you use a script that sets the field's value to empty (event.value = ""), the data is lost for calculation purposes. To prevent this, you must script the form to copy the selected value to a hidden text field before clearing the visible drop-down.
Are JavaScript form actions supported on all PDF viewers?
No. Advanced JavaScript triggers like 'Mouse Exit' or custom formatting scripts are generally only supported by fully-featured desktop PDF editors like Adobe Acrobat and WPS Office. Basic web browser PDF viewers or mobile readers may ignore these scripts.




