PDF Editing Issues

How to Show or Hide PDF Form Fields When a Checkbox is Selected

Khadija KhanKhadija Khan Nov 3, 2026 869 views

Question details

The user wants to configure a PDF form so that specific fields dynamically appear or hide based on whether a checkbox is selected.

How to Show or Hide PDF Form Fields When a Checkbox is Selected
Product
PDF Editor
Device & OS
not provided
Scenario
Creating interactive and conditional PDF forms where certain sections or questions are optional.
Observed behavior
Additional form fields need to become visible when a checkbox is checked and hidden when it is cleared.
Before you start

Ensure you are using a PDF editor that supports form field creation and JavaScript execution, such as Adobe Acrobat Pro or compatible professional PDF editing software.

Solution 1Recommended

Use JavaScript to Control Field Visibility via Checkbox

Add a custom Mouse Up script to the checkbox to dynamically change the display property of the target fields.

PDF forms support JavaScript to add interactive logic. By adding a simple script to a checkbox's action triggers, you can control whether other fields (like text boxes or dropdowns) are visible or hidden depending on the checkbox's state.

1
Create the Form Fields

Open your PDF editor, enter form editing mode, and create both the trigger checkbox and the target text fields or sections you want to control.

2
Access Checkbox Properties

Right-click the newly created checkbox and select 'Properties' from the context menu.

3
Add a Mouse Up Action

Navigate to the 'Actions' tab. Select 'Mouse Up' from the Select Trigger dropdown menu, choose 'Run a JavaScript' from the Select Action menu, and then click 'Add'.

4
Enter the JavaScript Code

In the JavaScript editor, input the following code: this.getField('TargetFieldName').display = event.target.value !== 'Off' ? display.visible : display.hidden; Replace 'TargetFieldName' with the exact name of the field you want to hide or show.

5
Test the Form

Click 'OK' to save the script, close the properties dialog, and exit form editing mode. Test the form by checking and unchecking the box to ensure the target field appears and disappears correctly.

Use JavaScript to Control Field Visibility via Checkbox
Match Field Names Exactly: Ensure the target field name in the JavaScript exactly matches the name of the field you created. PDF JavaScript is case-sensitive, so 'AdditionalField' and 'additionalfield' are treated differently.
Efficient PDF Editing and Form Management

Edit and Manage PDF Forms Easily with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to read, fill, edit, and manage interactive PDF forms effortlessly.

  1. 1. Download and Install: Download WPS Office from the official website and install it on your computer or mobile device.
  2. 2. Open Your PDF Form: Launch WPS Office, click 'Open', and select your interactive PDF file.
  3. 3. Fill and Edit: Navigate to the 'Fill & Sign' or 'Form' tabs to interact with checkboxes, text fields, and conditional elements seamlessly.
  4. 4. Save and Export: Once completed, click the 'Save' icon or export the document to share it with others.
Easily view and fill out interactive PDF forms containing checkboxes and advanced fields.Seamlessly convert between PDF, Word, Excel, and PowerPoint formats.Lightweight, fast, and fully compatible with standard Adobe PDF document formats.Cross-platform support for Windows, Mac, Linux, Android, and iOS.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my PDF JavaScript working when I click the checkbox?

Ensure that the field name referenced in your script exactly matches the target field's name, including capitalization. Additionally, verify that JavaScript execution is enabled in your PDF reader's security preferences (usually found under Edit > Preferences > JavaScript).

Can I hide multiple fields with one checkbox?

Yes. You can repeat the this.getField('FieldName').display line of code in the same JavaScript window for each field you wish to hide or show, simply changing the 'FieldName' for each line.

Will conditional PDF form fields work on mobile devices?

Support for PDF JavaScript varies on mobile devices. While desktop applications like Adobe Acrobat or WPS Office can execute these scripts reliably, many default mobile PDF viewers or web browsers may not fully support interactive JavaScript features.