How to Show or Hide PDF Fields with Yes or No Radio Buttons
Question details
The user needs to dynamically show or hide specific PDF form fields based on whether a 'Yes' or 'No' radio button is selected.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Building an interactive PDF form where certain input fields should only be visible when a specific radio button choice is made by the responder.
- Observed behavior
- Form fields need to dynamically change their visibility state using a JavaScript trigger tied to the radio button group.
Ensure you are using a PDF editor with form editing capabilities and JavaScript support, such as Adobe Acrobat or WPS Office.
Configure JavaScript for Radio Button Visibility
Add a Mouse Up JavaScript action to your radio button group to evaluate the selected option and dynamically update the display properties of target fields.
By assigning a JavaScript action to the radio button group, you can trigger visibility changes whenever the user makes a selection. The script checks the export value of the selected button and updates the display property of the target fields accordingly.
Right-click the controlling radio-button group in your PDF form editor and select 'Properties'.
Go to the 'Options' tab. Ensure that the export value for the 'Yes' button is exactly 'YES'.
Switch to the 'Actions' tab. Select 'Mouse Up' as the trigger and 'Run a JavaScript' as the action, then click 'Add'.
Input the following code: this.getField("OtherFieldName").display = (event.target.value == "YES") ? display.visible : display.hidden;
Duplicate the line of code for each field you want to show or hide, replacing 'OtherFieldName' with the exact names of your target fields.

Create and Fill PDF Forms Efficiently with WPS Office
WPS Office offers robust PDF editing tools that let you easily manage, fill, and interact with complex PDF forms without worrying about underlying code.
- 1. Open WPS Office: Launch the application and open your PDF document using the WPS PDF editor.
- 2. Access Form Features: Click on the 'Form' tab to view and interact with text fields, radio buttons, and checkboxes.
- 3. Fill and Save: Interact with the form elements directly, then save your completed document with all formatting intact.

Frequently Asked Questions
Why isn't my PDF field hiding when I click 'No'?
This usually happens if the export value of the 'Yes' button doesn't exactly match the value in your script (e.g., 'Yes' vs 'YES'), or if the target field name is spelled incorrectly in the getField function.
Can I hide multiple fields with one radio button?
Yes, you can hide multiple fields by duplicating the JavaScript line in your Mouse Up action and updating the target field name for each respective field.
Do these JavaScript actions work on mobile PDF viewers?
JavaScript support varies widely among mobile PDF viewers. While it works reliably on desktop applications like Adobe Acrobat and WPS Office, some basic mobile PDF readers may ignore JavaScript visibility triggers.




