Skip to main content
New Participant
February 15, 2023
Answered

Java Script Count Specific Text

  • February 15, 2023
  • 1 reply
  • 2274 views

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!

This topic has been closed for replies.
Correct answer Nesa Nurani

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;

1 reply

Nesa Nurani
Nesa NuraniCorrect answer
Inspiring
February 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;
New Participant
February 15, 2023

Thank you so much that worked!!

New Participant
February 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.