Hi All,
I have 3 dropdowns (DD1, DD2, DD3) and one textfield (TF1) in repeating rows (not in a table). Each dropdown has two choices and the textfield is free-form. Outside of the rows (in a different subform) I want totals based on multiple criteria from the dropdowns and textfields.
The following script works great to get a total number of one choice from one dropdown.
this.rawValue = xfa.resolveNodes('form1.Form.row[*].DD1.[$.rawValue == "2"]').length;
Problem is how do I calculate the totals for the following based on the criteria listed in each row.
Find the totals for ML
Number of New Forms 1-2 Pages: (result should be 2)
Number of New Forms 3+ Pages: (result should be 1)
Number of Revised Form: (result should be 0)
In row #1: select “New” as a choice from DD1, “Form” as choice from DD2, “ML” as a choice from DD3 and enter “5” in TF1.
In row #2: select “New” as a choice from DD1, “Form” as choice from DD2 , “ML” as a choice from DD3 and enter “1” in TF1.
In row #3: select “New” as a choice from DD1, “Form” as choice from DD2, “ML” as a choice from DD3 and enter “2” in TF1.
In row #4: select “Revised” as a choice from DD1, “Series” as choice from DD2, “ML” as a choice from DD3 and enter “1” in TF1.
In row #5: select “New” as a choice from DD1, “Form” as choice from DD2, “PM” as a choice from DD3 and enter “1” in TF1.
Views
Replies
Total Likes
Try something like;
var mlNewForms1or2Pages = 0;
var mlNewFormsOver3Pages = 0;
var mlRevisedForms = 0;
var rows = xfa.resolveNodes('form1.Form.row[*]');
for (var i = 0, limit = rows.length; i < limit; i++)
{
var currentRow = rows.item(i);
if (currentRow.DD1.rawValue == "1") // new
{
if (currentRow.DD2.rawValue == "1") // form
{
if (currentRow.DD3.rawValue == "1") // ML
{
if (parseInt(currentRow.TF1.rawValue, 10) > 2)
{
mlNewFormsOver3Pages++;
}
else
{
mlNewForms1or2Pages++;
}
}
}
}
else // revised
{
if (currentRow.DD2.rawValue == "1") // form
{
if (currentRow.DD3.rawValue == "1") // ML
{
mlRevisedForms++
}
}
}
}
console.println(mlNewForms1or2Pages);
console.println(mlNewFormsOver3Pages);
console.println(mlRevisedForms);
To do the same using predicates you could do;
var mlNewForms1or2Pages = 0;
var mlNewFormsOver3Pages = 0;
var mlRevisedForms = 0;
mlNewForms1or2Pages = xfa.resolveNodes('form1.Form.row.[DD1 == 1 and DD2 == 1 and DD3 == 1 and TF1 <= 2]').length;
mlNewFormsOver3Pages = xfa.resolveNodes('form1.Form.row.[DD1 == 1 and DD2 == 1 and DD3 == 1 and TF1 > 2]').length;
mlRevisedForms = xfa.resolveNodes('form1.Form.row.[DD1 == 2 and DD2 == 1 and DD3 == 1]').length;
But if you wanted totals for all the permutations then this could become slow.
Regards
Bruce
Views
Replies
Total Likes