Converting Check Boxes into a number

New Here ,
May 23, 2019

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript, Windows

Views

57

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Converting Check Boxes into a number

New Here ,
May 23, 2019

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript, Windows

Views

58

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 23, 2019 0
try67 LATEST
Most Valuable Participant ,
May 23, 2019

Copy link to clipboard

Copied

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;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2019 0