How to Show and Hide PDF Form Fields with Radio Buttons
Question details
The user needs to set up radio buttons in a PDF form to dynamically show one related text field while hiding other unnecessary fields.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form where field visibility depends on user selection.
- Observed behavior
- The goal is to use radio button logic to make mutually exclusive choices trigger the display of specific fields without needing separate checkbox deselection scripts.
Ensure your PDF editing software supports form creation and JavaScript actions. Take note of the exact names of the text fields you intend to show or hide, as you will need to reference them accurately in your script.
Configure Mouse Up JavaScript for Radio Buttons
Assign a specific JavaScript action to the Mouse Up trigger of each radio button to control which text fields are visible or hidden.
Because radio buttons provide mutually exclusive choices, selecting one automatically overrides the others within the same group. This makes them perfect for conditionally displaying form fields without requiring complex deselection logic.
Open your PDF in form editing mode. Right-click the first radio button in your group and select 'Properties'.
Navigate to the 'Actions' tab within the Properties window. Select 'Mouse Up' from the 'Select Trigger' dropdown menu.
Choose 'Run a JavaScript' from the 'Select Action' dropdown menu and click the 'Add' button to open the editor.
In the JavaScript editor, type the code to show the related field and hide the others. For example: `this.getField("Text1").display = display.visible; this.getField("Text2").display = display.hidden;`.
Click 'OK' to save your script. Repeat this process for the remaining radio buttons in the group, ensuring you update the script each time so the correct target field is set to visible and the rest are hidden.

Manage Interactive PDF Forms with WPS Office
WPS PDF provides an intuitive and powerful environment for viewing, filling out, and managing interactive PDF forms. Easily handle documents containing dynamic fields and logic.
- 1. Download and Install: Get WPS Office from the official website and launch the application on your device.
- 2. Open Your PDF: Click on the 'PDF' tab and select your interactive PDF form from your local files.
- 3. Interact with Fields: Navigate through the document; WPS PDF will automatically recognize interactive form fields, allowing you to select radio buttons and enter text.
- 4. Save and Export: Fill out your required data and securely save or export your completed form for sharing.

Frequently Asked Questions
Why should I use a 'Mouse Up' trigger instead of 'Mouse Down' for form buttons?
The 'Mouse Up' trigger is standard practice for form buttons because it allows the user to cancel their selection by dragging the cursor away before releasing the mouse button, which helps prevent accidental inputs.
Do I need to write a script to uncheck the other radio buttons?
No. Radio buttons inherently provide mutually exclusive choices when they share the exact same group name in their properties. Selecting one will automatically deselect all others in that group.
What happens if a user prints the PDF with hidden fields?
Fields that are set to 'display.hidden' will not appear on the screen and will also not be printed. Only the currently visible fields associated with the selected radio button will show up on the physical printed copy.




