Skip to main content
December 31, 2018
Question

use the calculate function to count items in a list

  • December 31, 2018
  • 1 reply
  • 456 views

I have a form that will be used for entering names and times worked.  The list could have anywhere from 1 to 21 names at any given time.  I'm trying to find a calculation that will give me the total number of names entered on the list.  Any ideas?

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 31, 2018

Let's say the name fields are called Name1 to Name21. You can use this code as the custom calculation script of the field where you want to display the total number of names entered:

var total = 0;

for (var i=1; i<=21; i++) {

    if (this.getField("Name"+i).valueAsString!="") total++;

}

event.value = total;