Use an Acrobat Checkbox to Add a Proficiency Bonus with JavaScript
Question details
Calculate an Athletics score using the Strength modifier and a proficiency bonus controlled by a checkbox.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A character-sheet PDF has fields for a Strength modifier, a proficiency bonus, and an Athletics proficiency checkbox.
- Observed behavior
- The Athletics score should always include the Strength modifier and include the proficiency bonus only when the checkbox is selected.
Open the character-sheet PDF in Adobe Acrobat and check the exact names of the checkbox, Strength modifier, proficiency bonus, and Athletics result fields in Prepare a form. Make sure the two modifier fields contain numeric values.
Add a custom calculation script to the Athletics result field
Use this calculation to include the proficiency bonus only when the Athletics checkbox is selected.
The script treats the checkbox value "Off" as unchecked. Replace the example field names with the exact names in your PDF; field names are case-sensitive.
In Acrobat, open the PDF and select All tools > Prepare a form. Double-click the Athletics result field to open its properties.
Open the Calculate tab, select Custom calculation script, and click Edit. Enter: var strength = Number(this.getField("strmod").value); var proficiency = Number(this.getField("Prob").value); var checked = this.getField("athc").valueAsString !== "Off"; event.value = strength + (checked ? proficiency : 0);
Click OK and close the properties dialog, then use Preview in Prepare a form. Enter numeric modifiers and select and clear the Athletics checkbox; the result should change between Strength plus proficiency and Strength alone.
Return from Preview and select File > Save to keep the calculation in the form.

Work with character-sheet PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for viewing PDFs and working with Office documents. Its format compatibility makes it easy to bring existing files into your workflow. Use Acrobat to create and test the checkbox JavaScript, as WPS does not fix Acrobat form scripts.

Frequently Asked Questions
Where should I put the JavaScript in Acrobat?
In All tools > Prepare a form, open the Athletics result field's properties. On the Calculate tab, select Custom calculation script and click Edit.
How does the script know whether the checkbox is selected?
It checks the checkbox field's valueAsString against "Off". If the value is not "Off", the script adds the proficiency bonus.
What if my PDF uses different field names?
In Prepare a form, check each field's name in its properties, then replace "athc", "strmod", and "Prob" in the script with the exact names. Field names are case-sensitive.
Why is the calculated score incorrect or blank?
Check that the modifier fields contain numbers and that Acrobat JavaScript is enabled under Preferences > JavaScript. If the input fields are calculated, check their calculation order in Prepare a form.
Will every PDF viewer run the calculation?
PDF viewers vary in their support for Acrobat JavaScript. Test the saved form in the viewer where it will be used; a viewer that does not support the script may not update the score.




