Fix Acrobat JavaScript Logic for Hiding PDF Radio Buttons
Question details
The user needs to correct conflicting JavaScript logic in an Acrobat PDF form so that specific radio button options hide correctly when the 1000V option is selected.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Developing a dynamic PDF form where JavaScript is used to show or hide specific radio button options based on user voltage selections (480V, 600V, 1000V).
- Observed behavior
- Overlapping 'if' and 'else' conditions cause visibility commands to conflict, resulting in incorrect radio button options remaining visible when 1000V is selected.
Before modifying your form's JavaScript code, save a backup copy of your original PDF to prevent accidental data loss or irreversible syntax errors during editing.
Restructure the JavaScript Visibility Logic
Resolve conflicting visibility by resetting the entire radio button group to visible at the start of the script, then applying specific hiding conditions.
When overlapping 'if' and 'else' clauses contain conflicting visibility states, the PDF viewer may fail to hide the intended widgets. This typically happens when a script tries to hide specific options while simultaneously trying to restore visibility in separate 'else' blocks.
By setting a default baseline visibility for the entire group first, you eliminate the need for complex 'else' clauses that attempt to restore visibility, streamlining the execution logic.
Open your PDF in Acrobat and enter 'Prepare Form' mode to access the interactive fields.
Right-click the triggering field (such as the voltage dropdown or main radio group) and select 'Properties', then navigate to the 'Actions' tab.
Under 'Select Action', choose 'Run a JavaScript', then click 'Add' or 'Edit' to open the JavaScript Editor window.
Move the command that makes the entire radio button group visible to the very beginning of the script, outside all 'if' statements.
Rewrite your 'if' conditions to explicitly hide only the specific widgets that do not apply to the selected voltage (e.g., target and hide the 480V and 600V widgets when 1000V is selected).
Delete any commands inside 'else' clauses that attempt to make the group visible again, as the default visibility at the top of the script already handles this.

Easily Fill and Manage Interactive PDF Forms with WPS Office
If you need a reliable, lightweight alternative for handling interactive PDF documents, WPS Office provides a robust PDF reader and editor. It natively supports viewing, filling, and managing standard PDF forms with excellent format compatibility.
- 1. Install WPS Office: Download and install WPS Office for free from the official website.
- 2. Open Your PDF: Launch WPS PDF and open your interactive PDF form document.
- 3. Highlight Form Fields: Navigate to the 'Form' tab and enable field highlighting to easily spot fillable areas.
- 4. Interact with Controls: Click on radio buttons, checkboxes, and text fields to make your selections and input data.
- 5. Save the Document: Click 'Save' to preserve your filled form data natively without flattening the file.

Frequently Asked Questions
Why are my PDF radio buttons not hiding when selecting a new option?
This usually happens due to conflicting JavaScript logic where overlapping 'if' and 'else' statements override each other. Ensuring you reset the default visibility before applying any hiding conditions usually resolves the conflict.
Can I use the same JavaScript logic for checkboxes and radio buttons?
Yes, the basic visibility properties (such as display.visible and display.hidden) apply to both checkboxes and radio buttons. Just ensure you are targeting the exact widget names for each specific control in your script.
Does WPS PDF support interactive forms?
Yes, WPS PDF fully supports viewing, filling, and interacting with standard PDF forms, including checkboxes, text fields, dropdowns, and radio buttons. It offers excellent compatibility with forms created in Adobe Acrobat.
How do I access the JavaScript editor for forms in Adobe Acrobat?
Enter 'Prepare Form' mode, right-click the specific form field, choose 'Properties', navigate to the 'Actions' tab, select 'Run a JavaScript' from the dropdown, and click 'Edit'.




