Skip to main content
New Participant
January 25, 2022
Question

Count number of checked boxes

  • January 25, 2022
  • 1 reply
  • 3393 views

Hello,

I am sure this topic has been asked many of times. Reviewing others solutions, I could not derive my own. I have three templates that have checkboxes for Met, Not Met, and N/A. At the bottom of the template there are boxes for Total Met, Total Not Met, and Total N/A. I would like for the total boxes to reflect the sum of the corresponding check marked boxes. See PDF attached.

 

I have 2 other templates that are similar but vary in the number of Met, Not Met, and N/A boxes. The communities help, would be greatly appreciated.

 

Thanks in advance!

This topic has been closed for replies.

1 reply

JR Boulay
Community Expert
January 26, 2022

For each row you should use 3 boxes with the same name and a different export value.
This would allow the user to make only one choice, and the calculation of totals would be simpler.

 

Acrobate du PDF, InDesigner et Photoshopographe
New Participant
January 28, 2022

Thank you. Both suggestions were helpful. Naming all three boxes the same did result in allowing only one checked box. However, when I change the export to where I would like the total to go, it is blank. If I use the calculation function in the total box and set to met1, it counts all three boxes when one is checked.

 

When each box has its own name, it calculates fine, but that will be a tedious 100+modifications. Any suggestions?

Nesa Nurani
Community Expert
January 28, 2022

If you keep your naming like in your template (Met1, Met2, Met3...etc) you can use this script as custom calculation script of "Total Met" field:

var met = 0;
for( var i=1; i<=12; i++){
if(this.getField("Met"+i).valueAsString != "Off")met++;}
event.value = met == 0 ? "" : met;

 

Use same script for other fields just change field name in script.

If you have more then 12 fields change 12 to number of fields you have.