Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Counting all Yes from a dropdown

Community Beginner ,
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

1.3K

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 , 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;

Likes

Translate

Translate
Adobe Community Professional ,
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;

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

Copy link to clipboard

Copied

That worked! Thank you very 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
Community Beginner ,
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? 

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

Copy link to clipboard

Copied

Divide that value by 43.

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
Community Beginner ,
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?

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

Copy link to clipboard

Copied

LATEST

Under the Simplified Field Notation option enter:

text3 / 43

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