PDF Editing Issues

How to Show a PDF Form Field Based on Other Field Values

Steve KSteve K Oct 28, 2026 869 views

Question details

The user needs to display a conditional PDF form field or specific text based on the values entered into other fields.

How to Show a PDF Form Field Based on Other Field Values
Product
PDF
Device & OS
not provided
Scenario
Setting up advanced PDF form calculations where a field's visibility or value dynamically changes depending on user input in referenced fields.
Observed behavior
The visibility script fails to show the field properly due to incorrect JavaScript targeting or mismatched data types between numeric values and text strings.
Before you start

Ensure your PDF editor supports custom JavaScript for interactive form fields, and note down the exact names of the fields you intend to reference.

Solution 1Recommended

Configure Conditional Field Visibility Using JavaScript

Fix the JavaScript visibility script by using the correct display target syntax and ensuring exact value type matches.

When scripting conditional visibility in PDF forms, the script must accurately target the display property of the specific field. A common mistake is using `event.display` instead of `event.target.display`. Additionally, JavaScript strictly compares data types, so a numeric `0` will not match a formatted text string like `"0.00"`.

1
Access Field Properties

Right-click the PDF form field you want to conditionally display and select 'Properties' from the context menu.

2
Open the Calculation Tab

Navigate to the 'Calculate' tab in the Properties window and select the 'Custom calculation script' option.

3
Correct the Visibility Script

In your JavaScript code, use `event.target.display = display.visible;` (or `display.hidden`) to ensure the visibility state is applied to the intended form field.

4
Verify Referenced Values

Use the syntax `this.getField("FieldName").value` to pull data from other fields. Ensure your condition logic accounts for exact data type matches, specifically checking if the returned value is a numeric zero (0) or a formatted text string ("0.00").

Configure Conditional Field Visibility Using JavaScript
Test Your Form: After applying the script, close the properties window and test the form by entering different values into the referenced fields to confirm the visibility toggles correctly.
Advanced PDF Form Editor

Create and Manage Interactive PDF Forms with WPS Office

WPS Office provides a comprehensive suite of PDF tools, allowing you to easily design interactive forms, edit field properties, and ensure your documents look professional.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document you want to edit.
  2. 2. Navigate to Form Tools: Click on the 'Form' tab located in the top navigation ribbon.
  3. 3. Insert Form Fields: Select the desired form control, such as a 'Text Field', and click on the page to place it.
  4. 4. Adjust Properties: Double-click the inserted field to open the Properties panel, where you can customize its appearance and behavior.
Easily insert text fields, checkboxes, and drop-down menus into your PDFs.Seamlessly configure form field properties, including visibility and formatting.Fully compatible with standard PDF forms created in Adobe Acrobat and other major PDF tools.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my JavaScript fail to hide the PDF form field?

This usually happens when the script incorrectly targets the display object. Ensure you are using `event.target.display = display.hidden` rather than `event.display = display.hidden`.

How do I reference another field's value in a PDF script?

You can retrieve the value of another field by using the `this.getField("ExactFieldName").value` method in your custom JavaScript.

Can I set a PDF field to be hidden by default without coding?

Yes. Open the field's Properties, go to the 'General' tab, and change the 'Form Field' property dropdown from 'Visible' to 'Hidden'.