Skip to main content
Participating Frequently
February 5, 2019
Answered

Count Fields in an Array with Text in them

  • February 5, 2019
  • 1 reply
  • 710 views

I'm a complete NOOB at Java and just getting started in form creation in DC.

What I'm trying to do is have the Filed labeled PAX return a count of all Fields in the yellow Array that contain text. Any help is appreciated!

This topic has been closed for replies.
Correct answer try67

Use this code as the custom calculation script of your field:

var total = 0;

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

    var f = this.getField("Pax"+i);

    if (f.valueAsString!="") total++;

}

event.value = total;

1 reply

Participating Frequently
February 5, 2019

Also, the fields in the Array are titles Pax1-40

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 5, 2019

Use this code as the custom calculation script of your field:

var total = 0;

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

    var f = this.getField("Pax"+i);

    if (f.valueAsString!="") total++;

}

event.value = total;