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

Java Script Count Specific Text

Community Beginner ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

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

Views

1.7K

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

Votes

Translate

Translate
Community Expert ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

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;

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

Copy link to clipboard

Copied

Thank you so much that worked!!

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

Use field name like this:

"Mode of MeetingRow"+i+"_2"

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

Copy link to clipboard

Copied

LATEST

Thank you that worked!

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