• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get the total of the row containing radio buttons?

Contributor ,
Jan 21, 2023 Jan 21, 2023

Copy link to clipboard

Copied

I hope you can help with this issue.

I have created an assessment form with 12 rows that uses 4, 3, 2, 1, 0 radio buttons for rating.

What I wish is to total all those boxes with checks under Rating 4

a) Total all those boxes with check under Rating 4. Each check box would have a value of 4.

b) Total all those boxes with checks under Rating 3. Each check box would have a value of 3.

c) Total all those boxes with checks under Rating 2. Each check box would have a value of 2.

d) Total all those boxes with checks under Rating 1. Each check box would have a value of 1.

e) Total all those boxes with checks under Rating 0. Each check box would have a value of 0.

The result is placed on the Total (Row 11).

Example:

If Rating 4 of Rows 3, 6, and 9 are checked, the total would be 12

If Rating 3 of Rows 1, 2, 4, 5, and 7 are checked, the total would be 15

If Rating 2 of Rows 8 and 10 are checked, the total would be 4

 

Appreciate the help you can give. Thank you.

TOPICS
Create PDFs , How to , PDF forms

Views

1.0K

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 2 Correct answers

Community Expert , Jan 24, 2023 Jan 24, 2023

After the declaration of the fields array add either a semi-colon or a line-break:

"F02012"]

Votes

Translate

Translate
Community Expert , Jan 24, 2023 Jan 24, 2023

Thanks, good catch. I forgot to add semi-colon, to the script, but I had a line break, so it wasn't an error for me.
I added semi-colon to script above.

Votes

Translate

Translate
Community Expert ,
Jan 21, 2023 Jan 21, 2023

Copy link to clipboard

Copied

First remove calculations from all total fields you have, then use this in only one of the total fields as custom calculation script:

var total1 = 0,total2 = 0,total3 = 0,total4 = 0;
var fields = ["F02001","F02002","F02003","F02004","F02005","F02006","F02007","F02008","F02009","F02010","F02011","F02012"];
for(var i in fields){
if(this.getField(fields[i]).valueAsString == "1")total1+=1;
if(this.getField(fields[i]).valueAsString == "2")total2+=2;
if(this.getField(fields[i]).valueAsString == "3")total3+=3;
if(this.getField(fields[i]).valueAsString == "4")total4+=4;}
this.getField("F02013a").value = total4;
this.getField("F02013b").value = total3;
this.getField("F02013c").value = total2;
this.getField("F02013d").value = total1;

 

 

There is no point of calculating total of checkboxes with 0 since it will always be 0.

Votes

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
Contributor ,
Jan 23, 2023 Jan 23, 2023

Copy link to clipboard

Copied

Hi Nesa,

 

Appreciate the help but I am getting an error message saying "Syntax Error: missing; before statement 1: at line 2". See attached. Thank you.

Votes

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
Community Expert ,
Jan 24, 2023 Jan 24, 2023

Copy link to clipboard

Copied

I'm not getting any errors, did you try to copy/paste script?

Please post exactly the script you are trying to use or your file.

Votes

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
Community Expert ,
Jan 24, 2023 Jan 24, 2023

Copy link to clipboard

Copied

After the declaration of the fields array add either a semi-colon or a line-break:

"F02012"]

Votes

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
Community Expert ,
Jan 24, 2023 Jan 24, 2023

Copy link to clipboard

Copied

Thanks, good catch. I forgot to add semi-colon, to the script, but I had a line break, so it wasn't an error for me.
I added semi-colon to script above.

Votes

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
Contributor ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

Thank you so much Nesa and Try69 for the help. Computation is now working perfectly.

 

 

Votes

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
Community Expert ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

LATEST

67...

Votes

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