How to Calculate 100 Percent Total from Checkboxes in Acrobat PDF
Question details
The user needs to configure a 'Total' text field in a PDF form to calculate and display a percentage based on the number of selected checkboxes out of a total of 17.

- Product
- Adobe Acrobat PDF
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where checking boxes automatically contributes to a percentage score, reaching 100% when all 17 specific checkboxes are selected.
- Observed behavior
- The form requires a programmatic rule or script to read the true/false states of 'Check Box1' through 'Check Box17' and output their selected ratio into a designated total field.
Ensure all 17 checkboxes are correctly named with a consistent pattern (e.g., Check Box1 to Check Box17) and that you have inserted a designated Text Field ready to act as the Total box.
Add a Custom JavaScript Calculation to the Total Field
Use a custom script in the Text Field properties to loop through the checkboxes, count the selected ones, and calculate the final percentage.
PDF forms rely on JavaScript for complex custom calculations. By writing a short loop, you can count how many checkboxes are ticked and divide by the total number of checkboxes to get your percentage.
Enter form editing mode in your PDF editor. Right-click the 'Total' text field you created and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Calculate' tab. Choose the 'Custom calculation script' option and click the 'Edit' button.
Input a JavaScript loop that iterates 17 times. Use the 'this.getField()' method to check the value of 'Check Box1' through 'Check Box17'. If a box is selected (not equal to 'Off'), increment a counter variable.
Divide your counter variable by 17 (the total number of checkboxes) and multiply by 100 to get the percentage value. Assign this final number to 'event.value' so it displays in the Total field.
Switch to the 'General' tab in the Properties dialog box and check the 'Read-Only' box. This ensures users cannot manually overwrite the automatically calculated percentage.
Easily Build and Manage PDF Form Calculations in WPS Office
WPS PDF provides a comprehensive set of form building tools, allowing you to easily add checkboxes, text fields, and custom JavaScript calculations to create interactive and smart documents.
- 1. Open the PDF in WPS Office: Launch WPS Office and open your PDF document. Navigate to the 'Form' tab to access the form creation tools.
- 2. Add Checkboxes: Use the 'Check Box' tool to insert your 17 checkboxes onto the page. Double-click each one to name them sequentially.
- 3. Insert the Total Field: Click on 'Text Field' to insert a box for your total. Right-click it, select 'Properties', and navigate to the 'Calculate' tab.
- 4. Apply Custom Script: Choose the custom calculation option, paste your JavaScript to automate the percentage calculation, and save your dynamic PDF form.

Frequently Asked Questions
Why is my PDF calculation field showing a blank or incorrect value?
This usually happens if the field names referenced in your custom calculation script do not perfectly match the actual names of the checkboxes on the form, or if there is a syntax error in your JavaScript code.
Can I format the output to show the '%' symbol automatically?
Yes. In the Total field's properties, under the Format tab, you can select 'Percentage' as the format category. This automatically multiplies your decimal result by 100 and appends the '%' sign, which allows you to remove the '* 100' step from your custom script.
Does this custom calculation script work on mobile PDF readers?
Custom JavaScript calculations in PDFs are fully supported on robust desktop PDF editors. However, many basic or default mobile PDF viewers do not support JavaScript, which may prevent the calculation from updating when viewed on a smartphone.




