PDF Editing Issues

How to Show a Hidden PDF Form Field When Two Radio Buttons Are Selected

Chanuka GeekiyanageChanuka Geekiyanage Nov 3, 2026 869 views

Question details

The user needs to configure a PDF form so that a hidden field becomes visible only when a specific combination of two radio buttons from separate groups is selected.

How to Show a Hidden PDF Form Field Based on Two Radio Buttons
Product
PDF Editors
Device & OS
not provided
Scenario
Creating dynamic and interactive PDF forms that require conditional logic to show or hide fields based on user input.
Observed behavior
The target form field remains hidden until the correct export values are triggered by the selection of two specific radio buttons.
Before you start

Ensure you are using a PDF editor that supports interactive form field properties and custom JavaScript execution, and note down the exact field names of your radio button groups before proceeding.

Solution 1Recommended

Use a Custom Calculation Script to Show the Field

Apply a JavaScript snippet within the target form field's calculation properties to evaluate the radio button states and toggle the field's visibility.

This method uses standard PDF JavaScript to check the values of two distinct radio button groups continuously. When both defined conditions are met, the script updates the display property of the target field to visible; if the conditions are not met, the field remains hidden.

1
Access Field Properties

Open your PDF document in form editing mode, right-click the target field you want to conditionally hide or show, and select 'Properties'.

2
Navigate to the Calculate Tab

In the Properties dialog box, go to the 'Calculate' tab and select the 'Custom calculation script' option.

3
Enter the JavaScript Code

Click the 'Edit' button and enter the following JavaScript code: event.target.display = (this.getField("Q3").valueAsString == "Yes" && this.getField("OneYrPass").valueAsString == "No") ? display.visible : display.hidden;

4
Customize Field Names

Replace 'Q3' and 'OneYrPass' with the actual field names of your radio button groups, and update 'Yes' and 'No' with their respective export values.

5
Save and Test

Click 'OK' to save the script, close the properties window, and preview the form to test if the conditional logic functions correctly.

Verify Export Values: Ensure that the string values in your script exactly match the 'Radio Button Choice' or 'Export Value' defined in the Options tab of your radio buttons. These values are case-sensitive.

Edit and Manage Interactive PDF Forms with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to create, edit, and manage interactive PDF forms effortlessly. It offers intuitive tools to design dynamic documents with ease.

  1. 1. Open PDF: Launch WPS Office and open your PDF document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
  3. 3. Add Form Fields: Select 'Radio Button' or 'Text Field' to draw your form elements onto the page.
  4. 4. Edit Properties: Double-click the added fields to configure their properties, including export values, actions, and formatting.
Easily insert text fields, radio buttons, and checkboxes into any PDF document.Highly compatible with Adobe Acrobat PDF forms and standard JavaScript actions.Lightweight software that ensures smooth performance even with complex PDF files.Cross-platform support for editing PDFs on Windows, Mac, and mobile devices.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my custom calculation script not working in my PDF form?

The most common reason for a failing script is mismatched field names or export values. Ensure the names inside `this.getField("FieldName")` perfectly match your radio button group names, and verify that the expected values are case-sensitive.

Can I hide multiple fields based on the same radio button selections?

Yes, you can apply an identical custom calculation script to the properties of each target field you wish to hide or show. Alternatively, you can write a document-level script to control the display properties of multiple fields simultaneously.

Does this JavaScript work in all PDF viewers?

While this script works perfectly in standard desktop PDF editors like Adobe Acrobat and WPS PDF, some basic web browsers or lightweight mobile PDF viewers may not fully support advanced PDF JavaScript calculations.

How do I find the correct export value for a radio button group?

Right-click the specific radio button in form editing mode, select 'Properties', and go to the 'Options' tab. Look at the 'Radio Button Choice' or 'Export Value' box to find the exact string you need to use in your calculation script.