PDF Editing Issues

How to Fix Acrobat JavaScript If-Then Statement Not Updating Form Fields

Jason MillerJason Miller Nov 3, 2026 869 views

Question details

The user needs to make a PDF form field automatically and continuously update based on the value of another field using JavaScript.

How to Fix Acrobat JavaScript If-Then Statement Not Updating Form Fields
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating a dynamic PDF form where a 'Rating' text field updates automatically based on a calculated 'FS' score.
Observed behavior
The if-then JavaScript updates the field only once and fails to respond to subsequent changes in the score.
Before you start

Ensure you have access to the 'Prepare Form' tool in your PDF editor and that JavaScript is enabled in your application preferences.

Solution 1Recommended

Use Custom Calculation Script for the Target Field

Placing the script in the target field's calculation event ensures it triggers every time the source field changes.

When a script is placed in a validation or formatting event of the source field, it might not trigger correctly for all updates. Moving the logic to the Custom Calculation Script of the destination field (e.g., the Rating field) forces the PDF viewer to recalculate it whenever any dependent field changes.

1
Open Form Properties

Enter the 'Prepare Form' mode, right-click the target field (e.g., 'Rating'), and select 'Properties'.

2
Navigate to Calculate Tab

Click on the 'Calculate' tab at the top of the Properties dialog box.

3
Add Custom Script

Select 'Custom calculation script' and click the 'Edit' button.

4
Enter JavaScript Code

Input the conditional logic. For example: var score = Number(this.getField('FS').value); if (score >= 90) event.value = 'Very Effective'; else if (score >= 70) event.value = 'Effective'; else event.value = 'Ineffective';

5
Save and Test

Click 'OK' to save the script, close the properties window, and test the form by changing the source score.

Use Custom Calculation Script for the Target Field
Calculation Order: If you have multiple calculated fields, ensure the calculation order is correct so the source field calculates before the target field.
Edit PDF Forms Easily

Manage and Fill PDF Forms with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to view, fill, and manage interactive PDF forms seamlessly without complex scripting.

  1. 1. Open WPS Office: Launch WPS Office and click on 'PDF Edit' or open your existing PDF file.
  2. 2. Access Form Tools: Navigate to the 'Form' tab to view available form fields and interactive elements.
  3. 3. Fill or Edit: Click on the text fields to input data directly, or use the editing tools to modify the document layout.
  4. 4. Save Document: Click 'Menu' and select 'Save As' to export your filled or modified PDF form.
Fully compatible with standard PDF forms and Microsoft Office formatsLightweight and fast PDF reader and editorSupports adding text, signatures, and annotations to PDFsFree alternative to expensive PDF software
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF calculation script only run once?

This usually happens if the script is placed in a formatting or validation event rather than the Custom Calculation Script of the field itself. Moving it to the calculation event ensures it runs on every update.

How do I check the field calculation order in Acrobat?

In Prepare Form mode, go to the right-hand pane, click 'More' (or the options menu), and select 'Set Field Calculation Order'. Ensure the fields are listed in the exact order they should be calculated.

Do I need to convert field values to numbers in JavaScript?

Yes, PDF form field values are often treated as strings. Using `Number(this.getField('FieldName').value)` ensures the value is treated as a number for mathematical comparisons like greater than or less than.

Can I use WPS Office to fill out interactive PDF forms?

Yes, WPS Office includes a built-in PDF reader and editor that fully supports filling out standard interactive PDF forms, including those with basic calculations.