PDF Editing Issues

How to Show or Hide a PDF Form Field Based on Two Other Fields

Maira MehtabMaira Mehtab Nov 5, 2026 869 views

Question details

The user needs to conditionally display a specific PDF form field only when two distinct form fields contain exact numerical values, entirely bypassing the need for an intermediate calculation field.

How to Show or Hide a PDF Form Field Based on Two Other Fields
Product
PDF Editor
Device & OS
not provided
Scenario
Creating an advanced, interactive PDF form where certain sections or fields are revealed dynamically based on multiple user inputs.
Observed behavior
The target field requires a logic rule to automatically switch its display status to visible or hidden by directly comparing the values of two other source fields.
Before you start

Verify the exact names of the form fields you plan to reference, as PDF form scripting is strictly case-sensitive and relies on perfect name matching.

Solution 1Recommended

Use a Custom JavaScript Calculation

Apply a custom calculation script to the target field to evaluate the conditions of the other two fields and dynamically control its visibility.

By utilizing the built-in JavaScript capabilities of advanced PDF editors, you can pull the values of multiple fields simultaneously. Assigning this script to the target field ensures it continuously checks the source fields and updates its own display property automatically.

1
Open Form Editing Mode

Open your PDF document in your PDF editor and activate the form creation or editing mode to reveal all interactive fields.

2
Access Target Field Properties

Right-click the field you want to hide or show (e.g., 'Reveal_A') and select 'Properties' from the context menu.

3
Navigate to the Calculate Tab

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

4
Enter the Evaluation Script

Click the 'Edit' button and enter the following JavaScript code, adjusting the field names and values to match your form: var valA = this.getField('FieldA').value; var valB = this.getField('FieldB').value; if (valA == 75.5 && valB == 16.0) { event.target.display = display.visible; } else { event.target.display = display.hidden; }

5
Save and Test

Click 'OK' to save the script, close the Properties window, and exit form editing mode. Enter the exact target values into FieldA and FieldB to verify that Reveal_A becomes visible.

Use a Custom JavaScript Calculation
Script Triggering: Calculation scripts execute whenever any field in the PDF form loses focus or receives a keystroke input. Ensure your source fields are configured to format or calculate correctly so the target field updates instantly.
Dynamic PDF Form Creation

Create and Manage Dynamic PDF Forms with WPS Office

WPS Office provides robust PDF form creation and editing tools, allowing you to easily build interactive forms, insert text fields, checkboxes, and manage field properties seamlessly.

  1. 1. Open Your PDF: Launch WPS Office and open your PDF document using the PDF editor.
  2. 2. Enter Form Mode: Navigate to the 'Form' tab on the top ribbon to access interactive form tools.
  3. 3. Add Form Fields: Click on 'Text Field', 'Check Box', or 'Dropdown' to insert new fields into your document.
  4. 4. Adjust Properties: Double-click any inserted field to open the Properties menu, where you can define field names, appearance, and formats.
Fully compatible with standard Adobe PDF forms and fieldsIntuitive form builder interface for quick field placementLightweight and fast interactive PDF editing experienceComprehensive suite for creating, editing, and protecting PDF documents
microsoft office alternative - wps office

Frequently Asked Questions

Can I use text values instead of numbers for the field condition?

Yes, you can evaluate text strings by placing the expected values in quotation marks within the script, such as `if (valA == 'Yes' && valB == 'Approved')`.

Why is the target field not hiding when the conditions are false?

This usually happens due to mismatched field names in the script or because the source fields haven't triggered a recalculation. Double-check that capitalization matches exactly and try pressing 'Enter' or clicking outside the source fields to trigger the calculation.

Do I need to place the script in the source fields instead?

No, it is highly recommended to place the display logic in the Custom Calculation Script of the target field itself. This allows the target field to evaluate its own visibility status whenever the global PDF form calculation is triggered.