How to Undo a Button Action That Hides PDF Form Fields
Question details
The user needs a way to reverse a button action in a PDF form that hides optional signature fields, because the standard Undo command does not work.

- Product
- PDF Editors
- Device & OS
- not provided
- Scenario
- Editing or interacting with a PDF form where a button triggers a script to hide specific fields.
- Observed behavior
- Clicking the button hides the fields as intended, but the standard 'Edit > Undo' command fails to reverse this visibility change.
Ensure you have access to the interactive form editing tools in your PDF software and know the exact name of the form field you want to show or hide.
Use a JavaScript Toggle Script on the Same Button
Since standard undo commands do not affect JavaScript-driven changes, the most efficient approach is to configure the button to toggle the field's visibility on each click.
PDF editors do not track JavaScript execution in their standard Undo history. To fix this, you can modify the button's behavior so that clicking it repeatedly switches the target field between visible and hidden states.
Enter Form Edit mode in your PDF editor, right-click the button you are using to hide the fields, and select 'Properties'.
Go to the 'Actions' tab, select 'Mouse Up' as the trigger, and choose 'Run a JavaScript' from the Select Action dropdown menu.
Click 'Add' and input the following script: var f = this.getField("YourFieldNameHere"); f.display = (f.display == display.visible) ? display.hidden : display.visible;
Replace 'YourFieldNameHere' with the actual name of your signature field, click 'OK' to save, exit Form Edit mode, and click the button to test the toggle effect.

Create a Dedicated 'Show Fields' Button
If you prefer having separate controls rather than a single toggle button, create a new button specifically programmed to restore the hidden fields.
View and Interact with PDF Forms Using WPS PDF
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily view, fill, and manage interactive PDF forms securely and efficiently.
- 1. Open your PDF Form: Launch WPS Office, go to the PDF section, and open your interactive PDF document.
- 2. Navigate to Form Tools: Click on the 'Form' tab on the top ribbon to access various form filling and viewing capabilities.
- 3. Interact with Fields: Click directly on the interactive fields or buttons to fill out information or trigger embedded actions.
- 4. Save Your Document: Once complete, click 'Save' to securely store your modified PDF document locally or on WPS Cloud.

Frequently Asked Questions
Why doesn't the standard Undo command work on PDF buttons?
The standard Undo command (Ctrl+Z) in PDF editors generally tracks text and layout edits. It does not track state changes triggered by background JavaScript actions, such as hiding or showing form fields.
Can I hide or show multiple PDF form fields with a single button?
Yes, you can modify the JavaScript to reference multiple fields. You can either repeat the script lines for each field name or define an array of field names and apply the toggle logic to each one using a loop.
Do JavaScript form buttons work on mobile PDF viewers?
JavaScript support varies significantly across mobile PDF viewers. While complex scripts work flawlessly on robust desktop applications like Acrobat and WPS PDF, many default mobile readers may ignore the script or fail to hide the fields.




