How to Calculate Goal Percentage in an Interactive PDF Form
Question details
The user needs to create a custom calculation in an interactive PDF form that compares an earnings field with a target amount to automatically output a goal percentage.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form for performance or financial tracking where percentage completion needs to be calculated automatically.
- Observed behavior
- The user wants to implement a specific logic where the percentage field correctly calculates earnings divided by target, while safely ignoring zero values or blank entries.
Verify the exact property names of your text fields (e.g., 'Earnings' and 'Target') in the PDF form editor before proceeding, as custom calculation scripts are case-sensitive.
Add a Custom JavaScript Calculation to the PDF Form Field
Implement a short JavaScript snippet in the target field's properties to divide earnings by the goal target, ensuring division-by-zero errors are handled properly.
A standard PDF sum or product calculation is insufficient for generating percentages dynamically. You will need to use a Custom Calculation Script to perform the division and conditionally handle empty or zero values.
Open your interactive document in a professional PDF editor. Navigate to the 'Form' or 'Prepare Form' tool to view all the interactive text fields.
Right-click the text field where you want the percentage to appear and select 'Properties'. Go to the 'Format' tab, select 'Percentage' from the category dropdown, and specify the number of decimal places.
In the same Properties window, switch to the 'Calculate' tab. Select the 'Custom calculation script' option and click the 'Edit' button.
Enter the following logic into the script editor: retrieve the values of the Target and Earnings fields, check if the Target is greater than zero, and if so, divide Earnings by the Target. Otherwise, set the event value to blank.
Click 'OK' to close the script editor, then close the Properties dialog. Exit the form editing mode and input test data into your Target and Earnings fields to ensure the percentage updates correctly.

Easily Edit and Calculate PDF Forms with WPS Office
WPS Office provides a comprehensive PDF toolkit that lets you design interactive forms, insert calculable fields, and apply custom formatting without needing expensive software.
- 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document using the built-in PDF reader.
- 2. Access Form Controls: Click on the 'Form' tab in the top navigation ribbon to access interactive fields like text boxes, checkboxes, and dropdowns.
- 3. Configure Field Properties: Double-click any text field to access its properties, where you can quickly set number formats and custom calculations.

Frequently Asked Questions
Why does my PDF show an error when the fields are empty?
This occurs because empty fields are treated as zero. If your script divides the earnings by the target (which is currently zero), it causes a division-by-zero error. You must use an 'if' statement in your script to ensure calculation only happens when the target is greater than zero.
Do custom PDF calculations work on mobile devices?
JavaScript support varies significantly across mobile PDF readers. While the calculation will work perfectly on desktop PDF software like WPS Office or Acrobat, some default mobile viewers may not execute the interactive scripts.
Can I calculate the percentage without using JavaScript?
While simple addition and multiplication can be done using the basic built-in calculation settings, determining percentages requires division and conditional logic, which necessitates using the 'Custom calculation script' option.




