How to Fix Acrobat JavaScript If-Then Statement Not Updating Form Fields
Question details
The user needs to make a PDF form field automatically and continuously update based on the value of another field using JavaScript.

- 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.
Ensure you have access to the 'Prepare Form' tool in your PDF editor and that JavaScript is enabled in your application preferences.
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.
Enter the 'Prepare Form' mode, right-click the target field (e.g., 'Rating'), and select 'Properties'.
Click on the 'Calculate' tab at the top of the Properties dialog box.
Select 'Custom calculation script' and click the 'Edit' button.
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';
Click 'OK' to save the script, close the properties window, and test the form by changing the source score.

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. Open WPS Office: Launch WPS Office and click on 'PDF Edit' or open your existing PDF file.
- 2. Access Form Tools: Navigate to the 'Form' tab to view available form fields and interactive elements.
- 3. Fill or Edit: Click on the text fields to input data directly, or use the editing tools to modify the document layout.
- 4. Save Document: Click 'Menu' and select 'Save As' to export your filled or modified PDF form.

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.




