PDF Editing Issues

How to Reset PDF Form Fields on Drop-Down Selection Change

Ayan MasoodAyan Masood Nov 5, 2026 870 views

Question details

The user needs to dynamically clear hidden text fields and update calculated fields based on the option a user selects from a drop-down menu in a PDF form.

How to Reset PDF Form Fields on Drop-Down Selection Change
Product
PDF Editor
Device & OS
not provided
Scenario
Creating an interactive PDF form where specific text fields must appear or disappear depending on a drop-down choice, and the data in the hidden fields must be cleared to prevent incorrect submissions.
Observed behavior
The form utilizes JavaScript to dynamically update field visibility, resetting the values of hidden fields and copying relevant values to calculated fields upon selection change.
Before you start

Ensure you have access to a professional PDF editor with form creation and JavaScript capabilities, such as Adobe Acrobat Pro or WPS Office, and verify the exact field names you wish to manipulate.

Solution 1Recommended

Use a Custom Calculation Script to Hide and Reset Fields

Add a custom calculation script to the drop-down field to automatically toggle the visibility of associated text fields and clear their contents when hidden.

By utilizing Acrobat JavaScript's display and resetForm methods, you can ensure that fields irrelevant to the current drop-down selection are not only hidden from the user but also wiped of any previously entered data.

1
Open Drop-Down Properties

Open your PDF form editor, right-click the drop-down field you want to trigger the action, and select 'Properties'.

2
Navigate to Custom Calculation

Go to the 'Calculate' tab and select 'Custom calculation script', then click the 'Edit' button to open the JavaScript editor.

3
Add Visibility Logic

Write an if-else statement using event.valueAsString. For example, if option 'dd1' is selected, set this.getField('Text1').display = display.visible; and set the unwanted fields to display.hidden.

4
Implement the Reset Command

Immediately after hiding the unwanted fields in your script, add the command this.resetForm(['Text3', 'Text4']); to clear the data from those specific hidden fields.

Use a Custom Calculation Script to Hide and Reset Fields
Field Names: Always double-check that the field names inside your JavaScript exactly match the names defined in your form's properties (they are case-sensitive).
Dynamic PDF Form Editor

Create and Edit Dynamic PDF Forms with WPS Office

WPS Office provides a comprehensive suite of PDF tools that allow you to quickly design interactive forms, insert drop-down menus, manage text fields, and configure properties to streamline your document workflows.

  1. 1. Open Your PDF: Launch WPS Office and open the PDF document you want to turn into an interactive form.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access the interactive form controls.
  3. 3. Insert Form Elements: Click on 'Drop-Down List' or 'Text Field' and drag the cursor on your page to place the interactive elements.
  4. 4. Configure Properties: Double-click the newly created form control to open its Properties panel, where you can define field names, appearance, and underlying values.
Easily insert interactive form controls like drop-downs, checkboxes, and text fields.Fully compatible with standard PDF forms and Adobe Acrobat formats.Lightweight, fast, and features a user-friendly interface for seamless document management.
microsoft office alternative - wps office

Frequently Asked Questions

Why aren't my hidden PDF fields clearing when I change the drop-down selection?

Hidden fields retain their data unless explicitly cleared. Merely setting the field to 'display.hidden' only removes it from view. You must include the 'this.resetForm(["FieldName"]);' JavaScript command to successfully delete the background data.

Where do I add the JavaScript in a PDF drop-down field?

Right-click the drop-down field and select 'Properties'. Depending on when you want the script to run, navigate to the 'Format', 'Validate', or 'Calculate' tab, select the option to run a custom script, and paste your JavaScript code there.

Are JavaScript PDF forms compatible with all PDF viewers?

Advanced JavaScript functions, like conditionally resetting form fields, require standard-compliant PDF readers such as Adobe Acrobat, WPS PDF, or Foxit. Basic browser-based PDF viewers often lack full JavaScript engine support and may not execute the scripts correctly.