How to Display Conditional Text Based on Numeric Range in PDF Forms
Question details
The user needs a way to automatically display specific text outputs in a dynamic PDF form based on the calculated numeric range of another field using JavaScript.

- Product
- Adobe PDF Forms
- Device & OS
- not provided
- Scenario
- Creating dynamic PDF forms where target text fields must automatically update their displayed text depending on the numeric score inputted or calculated in a source field.
- Observed behavior
- The user wants the target text field to evaluate a source numeric field using conditional logic (such as if/else loops) and display matching categories like 'Low Risk' or 'High Risk'.
Ensure that your PDF editing software supports JavaScript for interactive forms and that you have identified the exact exact field name of the source numeric data you plan to reference.
Apply a Custom Calculation Script using event.value
Use an if-else JavaScript condition loop in the target text field's Calculate tab to evaluate the source field and set the current field's value.
In PDF forms, the most reliable way to set a field's value based on another is to run a custom calculation script directly on the target field. By assigning the string result to 'event.value', the text field will update dynamically whenever the referenced source field changes.
Open the PDF in your form editor, right-click the target text field where you want the conditional text to appear, and select 'Properties'.
In the Text Field Properties dialog box, click on the 'Calculate' tab to view the calculation options.
Select the 'Custom calculation script' option, then click the 'Edit' button to open the JavaScript editor.
Enter the conditional script using event.value. For example: var score = Number(this.getField("SourceScoreField").valueAsString); if(score < 0.25) { event.value = "Low Risk"; } else if(score >= 0.25 && score <= 1.125) { event.value = "Medium Risk"; } else { event.value = "High Risk"; }
Click 'OK' to save your script, close the properties window, and test your form by entering different numeric values into the source field.

Create and Manage PDF Forms Easily with WPS Office
WPS Office offers a comprehensive PDF editor that allows you to effortlessly view, fill, edit, and manage PDF documents and interactive forms without needing expensive, heavy software.
- 1. Launch the PDF Editor: Open WPS Office and click on the 'PDF' tab from the home screen to launch the dedicated PDF editor.
- 2. Open Your Form: Click 'Open' to import your existing PDF form or start from a blank document to create a new one.
- 3. Fill or Edit: Navigate to the top toolbar to interact with text fields, add signatures, or modify document contents.
- 4. Save and Export: Save your finalized document. The output remains fully compatible with all standard PDF readers across different platforms.

Frequently Asked Questions
Why is my PDF calculation script not updating the text field automatically?
This usually happens if the form's calculation order is incorrect. Ensure that the source numeric field is calculated before the target text field. You can adjust this order in your PDF editor by navigating to the form tools and selecting 'Set Field Calculation Order'.
Can I use 'this.getField().value' instead of 'event.value' to set the target text?
While it is possible in document-level scripts or action triggers (like clicking a button), when writing a calculation script inside the target field itself, standard practice requires using 'event.value = "Your Text"' to ensure reliable dynamic updates.
Does the JavaScript numeric range script work on mobile PDF readers?
JavaScript support varies significantly across mobile PDF readers. Advanced form calculations and custom validation scripts often require a desktop-class PDF application (like Adobe Acrobat or full-featured desktop readers) to execute reliably.




