How to Hide a PDF Form Field Based on a Radio Button Selection
Question details
The user needs to dynamically hide or show specific PDF form fields (such as an Employer field) based on the selection of a specific radio button choice.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where certain input fields should only be visible when relevant conditions are met via radio button selections.
- Observed behavior
- Fields need to toggle between visible and hidden states automatically when the user interacts with the linked radio buttons.
Ensure your PDF editing software supports JavaScript for form fields, and note the exact names (case-sensitive) of the form fields you wish to target before adding scripts.
Use JavaScript to Control Form Field Visibility
Add a custom JavaScript code to the Mouse Up action of your radio button to dynamically hide or show dependent fields based on the selected value.
By applying a short JavaScript snippet to the radio button's properties, you can control the display state of any other field in the document. This method evaluates the radio button's value and sets the target field to either 'display.hidden' or 'display.visible'.
Enter form editing mode in your PDF editor. Right-click the radio button field you want to use as the trigger and select 'Properties'.
In the Properties dialog, go to the 'Actions' tab. Select 'Mouse Up' from the 'Select Trigger' drop-down menu.
Choose 'Run a JavaScript' from the 'Select Action' drop-down list, then click the 'Add' button.
Enter the following script in the editor window: this.getField("Employer").display = event.target.value == "No" ? display.hidden : display.visible; (Replace "Employer" with your actual target field name, and "No" with the export value of the radio button that triggers the hidden state).
Click 'OK' to save the script, then close the Properties dialog. Exit form editing mode to test the radio buttons and ensure the field hides and shows correctly.

Hide Multiple Fields or Use Complex Conditions
If you need to hide several fields at once or base visibility on a combination of checkboxes and radio buttons, you can expand the JavaScript logic.
Create and Manage Interactive PDF Forms Easily with WPS Office
WPS Office offers a robust set of PDF editing tools, allowing you to easily create interactive forms, add text fields, insert radio buttons, and manage PDF documents effortlessly without complex programming.
- 1. Download and Open WPS Office: Launch WPS Office on your device and navigate to the PDF tab.
- 2. Open Your PDF Document: Open the PDF file you wish to turn into an interactive form.
- 3. Access Form Tools: Click on the 'Form' tab in the top ribbon to reveal the interactive form controls.
- 4. Insert Form Fields: Select the desired field types (such as Radio Button or Text Field) and draw them onto your document, then double-click to adjust their properties.

Frequently Asked Questions
Why isn't my form field hiding when I click the radio button?
Ensure that the JavaScript trigger is set to 'Mouse Up' rather than 'Mouse Down'. Additionally, verify that the field names in your script perfectly match the actual form field names (which are case-sensitive) and that the export value in the script matches the radio button's designated export value.
Can I hide regular text added to the PDF along with the form field?
Standard text added to the base layer of a PDF cannot be dynamically hidden using form JavaScript. To hide text, you must convert the label into a read-only text form field, set its default value to your label text, and apply the same JavaScript visibility code to that specific field.
Is it possible to apply this visibility logic to drop-down lists instead of radio buttons?
Yes. You can use similar JavaScript on a drop-down list. You will typically assign the script to the 'Validate' or 'Format' tab of the drop-down field, or trigger it using a custom keystroke event to check the selected value.




