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

Count number of times values selected in a dropdown.

Community Beginner ,
Mar 08, 2024 Mar 08, 2024

Hello, 
First timer here, trying to automate an incident sheet for our fire co.
I'm trying to create scripts to count the number of members who responded on a certain vehicle.
We have a list of 40 people and there is a drop down next to their name. the dropdown has the vehicles list. 
EX: if we have 6 members respond on 52-12 , I would like the script to count the number of times 52-12 was selected in the drop-down and populate that on another field for a total. Simplifying things for the guys. 

Dave35953053a65j_0-1709921539083.pngexpand image

Dave35953053a65j_1-1709921595383.pngexpand image

 

 

TOPICS
JavaScript , PDF forms
678
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 Beginner ,
Mar 08, 2024 Mar 08, 2024

Dave35953053a65j_0-1709921802079.pngexpand image

 

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 ,
Mar 08, 2024 Mar 08, 2024

What are the names of the dropdown fields?

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 Beginner ,
Mar 08, 2024 Mar 08, 2024

the drop downs are labeled as the person's name (Last,First).  the spare at the end are "2" through "10"

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 Beginner ,
Mar 08, 2024 Mar 08, 2024

Dave35953053a65j_0-1709927590085.pngexpand image

 

 

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 ,
Mar 08, 2024 Mar 08, 2024
LATEST

You can use something like this code as the custom calculation script of the text field where you want to show the count of the "5212" values, for example:

 

var dropdowns = ["Yob, Jordan", "Doe, John"]; // etc.
var total = 0;
for (var i in dropdowns) {
	if (this.getField(dropdowns[i]).valueAsString=="5212v1") total++;
}
event.value = total;

 

Fill in the first line with the actual field names, and notice that the value used in the script is the export value, not the display one.

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