How to Show a Hidden PDF Form Field When Two Radio Buttons Are Selected
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.

- 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.
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.
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.
Open your PDF document in form editing mode, right-click the target field you want to conditionally hide or show, and select 'Properties'.
In the Properties dialog box, go to the 'Calculate' tab and select the 'Custom calculation script' option.
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;
Replace 'Q3' and 'OneYrPass' with the actual field names of your radio button groups, and update 'Yes' and 'No' with their respective export values.
Click 'OK' to save the script, close the properties window, and preview the form to test if the conditional logic functions correctly.
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. Open PDF: Launch WPS Office and open your PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
- 3. Add Form Fields: Select 'Radio Button' or 'Text Field' to draw your form elements onto the page.
- 4. Edit Properties: Double-click the added fields to configure their properties, including export values, actions, and formatting.

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.




