PDF Editing Issues

How to Show and Hide Radio Button Groups using JavaScript in Adobe Acrobat

Ayan MasoodAyan Masood Nov 24, 2026 869 views

Question details

The user wants to dynamically control the visibility of a radio button group in a PDF form using JavaScript based on a dropdown selection.

How to Show and Hide Radio Button Groups using JavaScript in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating interactive PDF forms where certain fields (like radio buttons) only appear when specific conditions in a dropdown menu are met.
Observed behavior
Needs the exact JavaScript syntax and method to toggle the display property of a grouped radio button field.
Before you start

Ensure you have Adobe Acrobat Pro installed, as the standard version or the free Adobe Reader does not support editing PDF forms or adding custom JavaScript.

Solution 1Recommended

Toggle Radio Button Group Visibility with JavaScript

Use Acrobat's built-in JavaScript editor to conditionally change the display property of grouped radio buttons.

To manage radio buttons effectively in Acrobat JavaScript, all buttons in the same group must share the exact same field name. You can then target this single group name to hide or show all associated buttons at once.

1
Open Prepare Form tool

Open your PDF form in Adobe Acrobat Pro and select the 'Prepare Form' tool from the right-hand pane.

2
Group your radio buttons

Ensure all radio buttons in your target group share the exact same 'Name' in their Properties (e.g., 'group1'). You can check this by right-clicking each radio button and selecting 'Properties'.

3
Add custom JavaScript

Right-click the dropdown field that will trigger the visibility change, select 'Properties', and navigate to the 'Format' or 'Calculate' tab to add a custom script.

4
Input the display code

Enter the JavaScript code: `if (event.value == 'TargetValue') { this.getField('group1').display = display.visible; } else { this.getField('group1').display = display.hidden; }`. Replace 'TargetValue' with your actual dropdown selection.

5
Test the form

Click 'OK', close the Properties dialog, and click the 'Preview' button at the top right to test your form and ensure the radio buttons hide and show correctly.

Toggle Radio Button Group Visibility with JavaScript
Syntax Note: The display properties in Acrobat JavaScript are predefined constants: display.visible, display.hidden, display.noPrint, and display.noView.
Free Microsoft Office alternative

Edit PDFs and Documents with WPS Office

While Adobe Acrobat is required for complex JavaScript form programming, WPS Office provides a comprehensive, lightweight, and free alternative for your daily document and PDF editing needs. It seamlessly integrates Word, Excel, PowerPoint, and powerful PDF tools into one familiar interface, making document management incredibly simple.

  1. 1. Download the software: Download and install WPS Office for free from the official website.
  2. 2. Open your PDF: Launch WPS Office and click on 'PDF Edit' or simply drag and drop your PDF document into the workspace.
  3. 3. Edit and save: Use the extensive top-menu tools to edit text, fill forms, merge pages, or effortlessly convert your PDF to Word formats.
Free and lightweight all-in-one office suiteBuilt-in PDF editor for reading, commenting, editing text, and basic form fillingHigh compatibility with Microsoft Office formats (DOCX, XLSX, PPTX)Seamless migration with an intuitive, tabbed user interface
microsoft office alternative - wps office

Frequently Asked Questions

Why is this.getField('group1') returning null in my Acrobat script?

This usually happens if the field name is misspelled in your script or if the field does not exist. Double-check that your radio buttons are named exactly 'group1' (case-sensitive) in their properties.

Can I hide individual radio buttons instead of the whole group?

Yes, but you must reference the specific widget index of the radio button. However, it is generally best practice to group them under one name and toggle the visibility of the entire group for simplicity.

Do these JavaScript actions work in Adobe Acrobat Reader?

Yes, once the scripts are added to a PDF form using Acrobat Pro and the file is saved properly, the JavaScript will execute correctly in the free Adobe Acrobat Reader when end-users fill out the form.

How do I hide text fields along with the radio buttons?

You can duplicate the display toggle line in your JavaScript and target the text field's name as well. For example: `this.getField('TextField1').display = display.hidden;`.