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

Java Script Count Specific Text

Community Beginner ,
Feb 15, 2023 Feb 15, 2023

Hello,

I am looking for a javascript to count the number of time a specific text "Face to Face" appears in a series of text boxes (26 different text boxes).  How many times does that word appear in these boxes.  The name of the text box is Mode of MeetingRow1 Mode of Meeting Row2 etc?  This is similar to excel for =COUNTIF(C9:C19,"Face to Face")

Thank you!

TOPICS
JavaScript
2.1K
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 15, 2023 Feb 15, 2023

Use this in a field where you want to show count number as 'custom calculation script':

var count = 0;
for(var i=1; i<=26; i++){
if(this.getField("Mode of Meeting Row"+i).valueAsString == "Face to Face")count++;}
event.value = count == 0 ? "" : count;

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 15, 2023 Feb 15, 2023

Use this in a field where you want to show count number as 'custom calculation script':

var count = 0;
for(var i=1; i<=26; i++){
if(this.getField("Mode of Meeting Row"+i).valueAsString == "Face to Face")count++;}
event.value = count == 0 ? "" : count;
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 ,
Feb 15, 2023 Feb 15, 2023

Thank you so much that worked!!

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 ,
Feb 20, 2023 Feb 20, 2023

Hello,  I asked for help with a formula a while ago and I realized that I need a similar formula on the next page  this is the original formula:

var count = 0;
for(var i=1; i<=26; i++){
if(this.getField("Mode of MeetingRow"+i).valueAsString == "Face to Face")count++;}
event.value = count == 0 ? "" : count;

 

But the rows for the new page now are Mode of Meeting1_2 to 26_2.  I tried this formula

var count = 0;
for(var i=1_2; i<=26_2; i++){
if(this.getField("Mode of MeetingRow"+i).valueAsString == "Face to Face")count++;}
event.value = count == 0 ? "" : count;

 

but it didn't work.  Any thoughts on how to edit this?

 

Thank you.

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 20, 2023 Feb 20, 2023

Use field name like this:

"Mode of MeetingRow"+i+"_2"

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 ,
Feb 20, 2023 Feb 20, 2023
LATEST

Thank you that worked!

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