How to Calculate a Performance Rating Letter in a PDF Form
Question details
The user needs to automatically populate a text field with a letter grade (A through E) based on a numerical value calculated in another field.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Setting up a performance review PDF form where a final score dynamically outputs a specific performance rating category.
- Observed behavior
- Requires a custom JavaScript calculation logic for a destination text field to read a number from a source field and display a corresponding letter rating.
Verify that both your numerical source field (e.g., 'text.42') and your destination rating field (e.g., 'text.50') have been created and are correctly named in your PDF form.
Use a Custom Calculation Script with JavaScript
Apply a simple JavaScript snippet to the destination field to evaluate the numeric input and output the appropriate letter grade.
Interactive PDF forms allow you to use standard JavaScript syntax to perform logic-based calculations. By adding an 'if/else if' statement to your destination field, it will dynamically evaluate the source field's number and update its own text value accordingly.
Open your PDF file in your PDF editor and enter the 'Prepare Form' or 'Edit Form' mode to view all fillable fields.
Right-click the destination text field where you want the letter grade to appear (e.g., 'text.50') and select 'Properties' from the context menu.
In the Text Field Properties dialog box, click on the 'Calculate' tab located at the top.
Select the 'Custom calculation script' radio button and click 'Edit'. Paste the following code into the JavaScript editor: var rating = Number(this.getField("text.42").valueAsString); if (rating < 1) { event.value = "A"; } else if (rating < 2) { event.value = "B"; } else if (rating < 3) { event.value = "C"; } else if (rating < 4) { event.value = "D"; } else { event.value = "E"; }
Click 'OK' to save your script, then close the properties window. Switch to 'Preview' mode and test the logic by inputting different values into your source field.

Easily Manage and Edit PDF Forms with WPS PDF
WPS Office provides robust PDF editing capabilities, enabling you to effortlessly create, modify, and manage fillable PDF forms without the need for heavy or expensive software.
- 1. Launch WPS Office: Open WPS Office and click on the 'PDF' tab from the home screen.
- 2. Open the PDF file: Click 'Open' and select your performance evaluation PDF form.
- 3. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to easily add, manage, or configure fillable text fields and checkboxes.
- 4. Save and share: Once your form fields are configured, save the document and share it for immediate use.

Frequently Asked Questions
Why is my PDF form calculation not updating automatically?
Make sure that the 'Automatically calculate field values' option is enabled in your PDF editor's preferences. Additionally, verify that the source field contains a valid number and that there are no syntax errors in your JavaScript code.
How do I ensure the calculation order is correct in my PDF?
If your source field ('text.42') is also calculated, you must ensure it computes before the destination field ('text.50'). This can be adjusted in the 'Calculation Order' settings found under the Form Editing tools of your PDF software.
Can I use different grading scales in the script?
Yes. You can customize the numerical thresholds (the numbers inside the 'if' and 'else if' parentheses) to perfectly match the rating ranges defined by your organization's performance standards.




