These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Count Items in Subform

tgizmo
Registered: Jun 14 2009
Posts: 8
Answered

I've done this before but can't remember how.
I have a LiveCycle form with 20 rows (instances) of employee data. One of the employee fields is gender (drop-down, "M" or "F").
 
How do I count the number of Males and Females in a summary form? Similar to countif function in Excel but ???. I apologize for the stupid question and appreciate any help.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
You can do this with a loop.

This script in the calculate:Event will count all rawValues of fields "Cell2" in all instances of Row1.
  1. var M = 0;
  2. var F = 0;
  3. for (var i=0; i < xfa.resolveNodes("Table1.Row1[*].Cell2").length; i++) {
  4. if (xfa.resolveNode("Table1.Row1[" + i + "].Cell2").rawValue === "m") {
  5. M++;
  6. }
  7. else if (xfa.resolveNode("Table1.Row1[" + i + "].Cell2").rawValue === "f") {
  8. F++;
  9. }
  10. }
  11.  
  12. this.rawValue = M.toString() + "/" + F.toString();

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs