How does one sum a specific choice from a series of groups of radio buttons?

New Here ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

I have a list of about 25 questions.  They are radio buttons with the choice of Yes, No, Maybe.

Fields are set up as:

Q1 is set up as  Group1 (Choice1"Yes", Chioce2"No", Choice3"Maybe")

Q2 is set up as Group2 (Choice1"Yes", Chioce2"No", Choice3"Maybe")

All the way to Q25

Im trying to add all of the Yes (or choice1) answers in one field, all of the No (of choice2) answers another field and all of the Maybe (choice3) answers in another field.

When i try to calculate using the sum function i'm only able to choose groups and dont have the option to specify the choice fields.

Does anyone have any sugestions on how to add up the specific choice fields?  would be very much appreciated!!!

TOPICS
JavaScript, PDF forms

Views

110

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Apr 20, 2021 Apr 20, 2021
Lets say your 3 fields to show sum are called 'Yes', 'No' and 'Maybe', use this script as calculation script of 'Maybe' field: var y = 0; var n = 0; var m = 0; for ( var i=1; i<=25; i++){ if(this.getField("Group"+i).value == "Choice1")y++; if(this.getField("Group"+i).value == "Choice2")n++; if(this.getField("Group"+i).value == "Choice3")m++; if(y == 0 && n == 0 && m == 0){ this.getField("Yes").value = ""; this.getField("No").value = ""; event.value = "";} else{ this.getField("Yes").value = y; th...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Lets say your 3 fields to show sum are called 'Yes', 'No' and 'Maybe', use this script as calculation script of 'Maybe' field:

var y = 0;
var n = 0;
var m = 0;
for ( var i=1; i<=25; i++){
if(this.getField("Group"+i).value == "Choice1")y++;
if(this.getField("Group"+i).value == "Choice2")n++;
if(this.getField("Group"+i).value == "Choice3")m++;
if(y == 0 && n == 0 && m == 0){
this.getField("Yes").value = "";
this.getField("No").value = "";
event.value = "";}
else{
this.getField("Yes").value = y;
this.getField("No").value = n;
event.value = m;}}

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
community guidelines
New Here ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Thanks Nesa. I put that script in but its not calculating.   Im at a loss as to why

Screen Shot 2021-04-20 at 3.11.05 PM.png

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
community guidelines
Adobe Community Professional ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Check javascript for error. Check that all your fields are named correctly and that they have correct choices, if that doesn't help share your file so I can see whats going on.

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
community guidelines
New Here ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Script and field names seem fine to me...but i'm also the one who came onto the forum so its not saying much!!

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
community guidelines
Adobe Community Professional ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Your fields are named 'Group' not 'Q', so in script change "Q" with "Group" it was my mistake I thought your fields are named Q.

EDIT: I fixed code above.

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
community guidelines
New Here ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

LATEST

Works like a charm!  Thanks for yoru help Nesa!!!  great appreciated

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
community guidelines