Calculate number of radio groups answered

New Here ,
Sep 14, 2018

Copy link to clipboard

Copied

I have three radio groups rg1, rg2 and rg3 with 6 option in each. I can calculate the sum of the three selection in each radio group easily. But I also need a text field calculation the number of radio groups checked. So if two of the radio groups are answered the text field should show 2. Is it done with a simple java script? And what would it look like?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Yes, this can be done with the following custom calculation script:

var total = 0;

for (var i=1; i<=3; i++) {
    if (this.getField("rg"+i).valueAsString!="Off") total++;
}

event.value = total;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

72

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

Calculate number of radio groups answered

New Here ,
Sep 14, 2018

Copy link to clipboard

Copied

I have three radio groups rg1, rg2 and rg3 with 6 option in each. I can calculate the sum of the three selection in each radio group easily. But I also need a text field calculation the number of radio groups checked. So if two of the radio groups are answered the text field should show 2. Is it done with a simple java script? And what would it look like?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Yes, this can be done with the following custom calculation script:

var total = 0;

for (var i=1; i<=3; i++) {
    if (this.getField("rg"+i).valueAsString!="Off") total++;
}

event.value = total;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

73

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
Sep 14, 2018 0
Most Valuable Participant ,
Sep 14, 2018

Copy link to clipboard

Copied

Yes, this can be done with the following custom calculation script:

var total = 0;

for (var i=1; i<=3; i++) {
    if (this.getField("rg"+i).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...
Sep 14, 2018 1
New Here ,
Sep 14, 2018

Copy link to clipboard

Copied

Yes man! works perfectly

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...
Sep 14, 2018 0