Create a Checkbox-Based PDF Calculation in Adobe Acrobat
Question details
Calculate a PDF form value only when a checkbox is selected, and return zero otherwise.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A PDF form needs a result field whose calculation depends on a checkbox and a numeric input field.
- Observed behavior
- The result field should display the calculated amount when the checkbox is selected and zero when it is unchecked.
Open the form in a version of Adobe Acrobat that supports editing form fields. Identify the exact names of the checkbox, numeric input, and result fields in Prepare a Form.
Add a custom calculation script to the PDF result field
Use Acrobat JavaScript to check the checkbox state and calculate the result or return zero.
Open the PDF in Adobe Acrobat and select All tools > Prepare a form.
Double-click the checkbox and numeric input fields to inspect their names in Properties. Note the exact spelling, including spaces and capitalization.
Double-click the result field, open the Calculate tab, select Custom calculation script, and click Edit.
Paste: if (this.getField("Check Box36").valueAsString != "Off") { event.value = Number(this.getField("y").value) * 0.38 * 100; } else { event.value = 0; } Replace "Check Box36" and "y" with your field names and adjust the rate and multiplier for your formula.
Click OK to save the script, close Properties, and save the PDF. Enter a number in the input field, then select and clear the checkbox to verify both results.

Edit PDF and Office files with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office files. It can help you move between common document formats, but it does not replace Acrobat's custom form calculation script editor.

Frequently Asked Questions
How does the script tell whether the checkbox is selected?
It checks the checkbox field's valueAsString. An unchecked Acrobat checkbox has the value "Off"; the script calculates when the value is anything else.
Where do I change the calculation rate?
In the result field's Properties, open Calculate > Custom calculation script > Edit. Replace 0.38 and, if necessary, the multiplier 100 with the values required by your formula.
Why does the calculation work in Acrobat but not in another PDF viewer?
Some PDF viewers do not support Acrobat JavaScript or have it disabled. Open the saved form in Acrobat with JavaScript allowed and test it in the intended recipient's viewer.
What should I check if the result does not update correctly?
In Prepare a form, verify that the field names in the script exactly match the checkbox and input field names. Also check that the input is numeric and that the script is attached to the result field's Calculate tab.




