PDF Editing Issues

How to Show or Hide PDF Fields with Yes or No Radio Buttons

Emma BrownEmma Brown Nov 10, 2026 869 views

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.

How to Show or Hide PDF Fields with Yes or No Radio Buttons
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.
Before you start

Ensure you are using a PDF editor with form editing capabilities and JavaScript support, such as Adobe Acrobat or WPS Office.

Solution 1Recommended

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.

1
Access Radio Button Properties

Right-click the controlling radio-button group in your PDF form editor and select 'Properties'.

2
Verify Export Values

Go to the 'Options' tab. Ensure that the export value for the 'Yes' button is exactly 'YES'.

3
Add JavaScript Action

Switch to the 'Actions' tab. Select 'Mouse Up' as the trigger and 'Run a JavaScript' as the action, then click 'Add'.

4
Enter the Script

Input the following code: this.getField("OtherFieldName").display = (event.target.value == "YES") ? display.visible : display.hidden;

5
Customize for Multiple Fields

Duplicate the line of code for each field you want to show or hide, replacing 'OtherFieldName' with the exact names of your target fields.

Configure JavaScript for Radio Button Visibility
Case Sensitivity: JavaScript is case-sensitive. Ensure that the export value ('YES') in your code perfectly matches the export value set in the radio button properties.
Advanced PDF Editing

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. 1. Open WPS Office: Launch the application and open your PDF document using the WPS PDF editor.
  2. 2. Access Form Features: Click on the 'Form' tab to view and interact with text fields, radio buttons, and checkboxes.
  3. 3. Fill and Save: Interact with the form elements directly, then save your completed document with all formatting intact.
Seamlessly fill and manage interactive PDF formsFully compatible with standard Adobe Acrobat PDF formatsLightweight, fast, and user-friendly interfaceCross-platform support for seamless workflow
QA img-9

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.