PDF Editing Issues

How to Display PDF Form Results Based on Another Field Using Acrobat JavaScript

Bushra ParveenBushra Parveen Nov 5, 2026 869 views

Question details

The user needs to use a custom JavaScript calculation in a PDF to conditionally display a specific value based on the input of another field.

How to Display PDF Form Results Based on Another Field Using Acrobat JavaScript
Product
Adobe Acrobat PDF Form
Device & OS
not provided
Scenario
Creating dynamic and interactive PDF forms with conditional logic.
Observed behavior
The target field needs to automatically update its value to match either Conclusion1 or Conclusion2 based on the input provided in the Gender field.
Before you start

Ensure you are in the PDF form editing mode and have accurately named your reference fields (e.g., 'Gender', 'Conclusion1', and 'Conclusion2') before applying the custom calculation script. Field names in JavaScript are strictly case-sensitive.

Solution 1Recommended

Use a Custom Calculation Script in Adobe Acrobat

Apply a JavaScript snippet to the target field's calculation properties to dynamically fetch and display values based on the referenced field.

To achieve this, you need to use Acrobat's built-in JavaScript engine. By reading the string value of the condition field (like 'Gender'), you can assign the corresponding text from other fields to the current field using 'event.value'.

1
Open Prepare Form Mode

Launch Adobe Acrobat, open your PDF document, and click on 'Tools' > 'Prepare Form' to enter form editing mode.

2
Access Field Properties

Right-click the target field (e.g., the Percentage or Results field) where you want the conditional result to appear, and select 'Properties' from the context menu.

3
Set Calculation Type

In the Properties dialog box, navigate to the 'Calculate' tab and select the radio button for 'Custom calculation script'.

4
Input the JavaScript Code

Click the 'Edit' button and paste the following code: var gender = this.getField("Gender").valueAsString; if (gender == "1") { event.value = this.getField("Conclusion1").valueAsString; } else if (gender == "2") { event.value = this.getField("Conclusion2").valueAsString; } else { event.value = ""; }

5
Save and Test

Click 'OK' to close the JavaScript editor, then click 'Close' on the Properties dialog. Click 'Preview' at the top right to test your form by entering "1" or "2" into the Gender field.

Use a Custom Calculation Script in Adobe Acrobat
Dynamic Updating: Once configured, the target field will instantly update its displayed text whenever the user modifies the value inside the Gender field and clicks outside of it.
Efficient PDF Form Management

Manage and Edit PDF Forms Easily with WPS Office

WPS Office provides a robust PDF toolkit that allows you to view, fill, edit, and manage interactive PDF forms effortlessly without needing expensive software.

  1. 1. Install WPS Office: Download and install the free version of WPS Office from the official website.
  2. 2. Open Your PDF: Launch WPS PDF and open the interactive PDF form document you need to fill out or manage.
  3. 3. Fill and Edit: Use the intuitive 'Form' tools provided to quickly fill out text fields, check boxes, or apply your digital signature.
  4. 4. Save and Export: Save your completed form locally or share it directly while maintaining full layout and data integrity.
Seamlessly fill and interact with complex interactive PDF forms.Highly compatible with standard Adobe Acrobat PDF formats and form fields.Lightweight, fast, and features a highly intuitive user interface.Comprehensive tools for editing text, adding signatures, and adjusting PDF layouts.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my PDF JavaScript calculation working?

This usually happens if the field names in your script do not exactly match the actual field names in your PDF form. Field names are case-sensitive. Check your 'Gender', 'Conclusion1', and 'Conclusion2' field properties to ensure they match exactly.

Can I hide the conclusion fields so users only see the final result?

Yes. You can set the 'Conclusion1' and 'Conclusion2' fields to 'Hidden' in their Properties under the General tab. The JavaScript will still be able to run silently, read their values, and display the result in your visible target field.

How do I trigger the calculation script to run?

Calculation scripts automatically trigger whenever any field value in the PDF changes. To test it, simply enter a value like '1' or '2' into the referenced field and hit Enter, or click anywhere outside the field. The result will display immediately.