Skip to main content
Participant
May 23, 2019
Question

Converting Check Boxes into a number

  • May 23, 2019
  • 1 reply
  • 275 views

I have a list of items labeled Check Box 1 to Check Box 30.  I need to calculate how many actually get checked.  I am so new to this so step by step would be helpful.

Thanks!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 23, 2019

You can use this code as the custom calculation script of the field where you want to display the result:

var total = 0;

for (var i=1; i<=30; i++) {

    var fname = "Check Box "+i;

    var f = this.getField(fname);

    if (f==null) {app.alert("Error! Can't find: " +fname); continue;}

    else if (f.valueAsString!="Off") total++;

}

event.value = total;