How to Show or Hide Text Fields Based on PDF Radio Button Selection
Question details
The user needs a dynamic PDF form where specific questions and text fields are displayed or hidden depending on which radio button option the respondent selects.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Creating an interactive data collection form that adapts its questions based on user choices.
- Observed behavior
- The form requires logic to toggle the 'Visible' or 'Hidden' display properties of designated fields according to the current radio button combination.
Ensure all your text fields and radio buttons are fully created and correctly named in your PDF before applying visibility rules, as changing field names later can break the logic.
Use Built-in Form Actions to Toggle Field Visibility
This method uses the standard PDF field properties to show or hide fields without writing any code, ideal for straightforward 'Yes/No' dynamic forms.
By utilizing the 'Show/hide a field' action in the radio button's properties, you can define exactly which text fields appear on the page when a user clicks a specific option. You will need to set this up for every radio button in the group to ensure fields disappear when an alternative option is chosen.
Open your PDF in form editing mode. Right-click the first radio button and select 'Properties' from the context menu.
Navigate to the 'Actions' tab. From the 'Select Trigger' drop-down, choose 'Mouse Up'. From the 'Select Action' drop-down, choose 'Show/hide a field', then click the 'Add' button.
A dialog box will appear listing all form fields. Select the text fields or questions you want to control. Click the 'Show' or 'Hide' radio buttons at the bottom of the dialog to set their status when this specific radio button is clicked, then click 'OK'.
Crucially, you must repeat this process for the other radio buttons in the group. If selecting 'Option A' shows a field, selecting 'Option B' must have an action configured to hide that same field.

Use Document-Level JavaScript for Complex Logic
For forms with multiple overlapping conditions or numerous fields, using custom JavaScript provides better control and efficiency than adding dozens of manual actions.
Create Advanced Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF toolkit that allows you to easily design interactive forms. You can insert radio buttons, customize text fields, and apply robust visibility actions to build dynamic, user-friendly documents.
- 1. Open Your PDF: Launch WPS Office and open your PDF document. Navigate to the 'Form' tab on the top ribbon.
- 2. Insert Form Controls: Use the toolbar to add your Radio Buttons and Text Fields onto the document page. Ensure fields in a single group share the same name.
- 3. Set Up Visibility Actions: Double-click a radio button to open its Properties. Go to 'Actions', select 'Show/hide a field', and define which questions should appear when selected.
- 4. Save and Distribute: Test your interactive form by clicking the options, then save your dynamic PDF to share with respondents.

Frequently Asked Questions
Why does a hidden text field not disappear when I select a different radio button?
Setting a field to 'Visible' on one radio button does not automatically hide it when you click another. You must open the Properties of the alternative radio button, add a 'Show/hide a field' action, and explicitly set the target text field to 'Hide'.
How do I group radio buttons together so only one can be selected?
To group radio buttons, they must all share the exact same 'Name' in their General Properties. However, you must give each button a unique 'Radio Button Choice' or 'Export Value' in the Options tab to distinguish them.
Will these dynamic form fields work if someone opens the PDF on a mobile phone?
It depends on the PDF reader app being used. Simple built-in 'Show/hide a field' actions are widely supported across major mobile PDF viewers, but complex custom JavaScript logic is often ignored by basic mobile readers. It is best to test the form on the intended devices.




