Show and Hide PDF Form Fields Based on Radio Button Choices
Question details
The user wants to create dynamic PDF forms where specific questions appear or disappear depending on the radio button choice selected by the respondent.

- Product
- Device & OS
- not provided
- Scenario
- Creating an interactive car request form where conditional fields are required based on user input.
- Observed behavior
- Needs specific fields to be hidden by default and only revealed when options like 'Ambulance' or 'Yes' are selected.
Ensure you are using a PDF editor that supports advanced form creation and JavaScript execution, and map out your conditional logic before adding scripts.
Use JavaScript Actions in Your PDF Editor
Apply custom JavaScript to radio buttons to control the visibility of secondary fields dynamically.
By default, PDF fields do not have built-in conditional logic without coding. To make fields appear based on a selection, you must hide the dependent fields first and then trigger a JavaScript action from the radio button.
Add all necessary radio buttons and text fields to your document, ensuring each field has a unique and easily identifiable name.
Right-click the field you want to hide (e.g., the 'number of steps' field), select Properties, navigate to the General tab, and change the Form Field property from Visible to Hidden.
Right-click your trigger radio button and choose Properties. Go to the Actions tab, choose 'Mouse Up' as the trigger, select 'Run a JavaScript' as the action, and click Add.
Write an if/else statement checking the selected value. For example: if (event.target.value == 'Ambulance') { this.getField('AssistanceQuestion').display = display.visible; } else { this.getField('AssistanceQuestion').display = display.hidden; }.

Create and Manage PDF Forms with WPS Office
WPS Office offers a comprehensive suite of PDF tools, allowing you to easily view, fill, and manage interactive PDF forms without complex configurations.
- 1. Open WPS Office: Launch WPS Office on your desktop and navigate to the PDF module.
- 2. Load your PDF: Click 'Open PDF' and select the form you wish to fill or edit.
- 3. Fill the form: Use the built-in form filling tools to check boxes, select radio buttons, and input text.
- 4. Save and export: Save your completed document or export it to share with others.

Frequently Asked Questions
Can I hide a PDF field without using JavaScript?
You can manually set a field's visibility to 'Hidden' in its properties, but making it appear or disappear dynamically based on user interaction always requires JavaScript.
Why is my PDF form JavaScript not working?
Ensure that JavaScript is enabled in your PDF viewer's security settings. Also, double-check that your script has no syntax errors and that the target field names match exactly.
Do conditional form fields work on mobile PDF viewers?
JavaScript-based conditional fields often do not work correctly on mobile devices or browser-based PDF viewers, as they require robust JavaScript support typically found only in desktop applications.
How do I make a hidden field visible again while editing?
In form editing mode, you can still select the hidden field. Right-click it, go to Properties, and under the General tab, change the visibility setting back to 'Visible'.




