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

Counting all Yes from a dropdown

Explorer ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

I have 43 dropdowns with the option of Yes or No. Need to count all the yes selections.

Named: Dropdown1-Dropdown43

What would be the script? Thanks in advance!

TOPICS
JavaScript

Views

2.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 1 Correct answer

Community Expert , May 11, 2021 May 11, 2021

You can use this code as the custom calculation script of the text field that should show the total number of "Yes" options selected:

 

var total = 0;
for (var i=1; i<=43; i++) {
	var f = this.getField("Dropdown"+i);
	if (f.valueAsString=="Yes") total++;
}
event.value = total;

Votes

Translate

Translate
Community Expert ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

You can use this code as the custom calculation script of the text field that should show the total number of "Yes" options selected:

 

var total = 0;
for (var i=1; i<=43; i++) {
	var f = this.getField("Dropdown"+i);
	if (f.valueAsString=="Yes") total++;
}
event.value = total;

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
Explorer ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

That worked! Thank you very much!!!!

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
Explorer ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

I have one more question, please. Now that I have the value of how many yes selections in my text3 box how can I calculate that into a percentage into a text4 box? 

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 ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Divide that value by 43.

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
Explorer ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Yes, but what would be the script be in text4 to calculate what was in text3 by 43?

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 ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

LATEST

Under the Simplified Field Notation option enter:

text3 / 43

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