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

Need Script Help With Adding Yes/No Columns

Explorer ,
Feb 23, 2022 Feb 23, 2022

Im trying to add all the "Yes" and all the "No's" in each column. I'm using the following script that does not seem to work for me. 

var total = 0; for (var i=1; i<=60; i++) { var fields = this.getField("Check Box "+i).getArray(); for (var j in fields) { if (fields[j].valueAsString!="Off") total++; } } event.value = total;

I named the check boxes 1-60 the same for each question with a differant value in each (yes,no), so the end user can not check a yes and no for the same answer. Need a little help on this script. Not sure what I'm doing wrong. 

Screen Shot 2022-02-23 at 1.07.22 PM.png

TOPICS
PDF forms
414
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 23, 2022 Feb 23, 2022

This script is not quite what you need. Use this:

 

var total = 0;
for (var i = 1; i <= 60; i++) {
	var f = this.getField("Check Box "+i);
	if (f.valueAsString=="yes")
		total++;
}
event.value = total;

 

Note that JS is case-sensitive, so "yes" and "Yes" are not the same thing...

View solution in original post

Translate
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 ,
Feb 23, 2022 Feb 23, 2022

This script is not quite what you need. Use this:

 

var total = 0;
for (var i = 1; i <= 60; i++) {
	var f = this.getField("Check Box "+i);
	if (f.valueAsString=="yes")
		total++;
}
event.value = total;

 

Note that JS is case-sensitive, so "yes" and "Yes" are not the same thing...

Translate
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
Explorer ,
Feb 23, 2022 Feb 23, 2022
LATEST

That did the trick. Thank you so much!!!!!!!

Translate
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