Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Total calculation for repeating item

Avatar

Level 1

I want to calculate the total for a field of repeating item, from the Level Scripting Support, the resolveNodes is supported in mobile HTML form. But after getting the repeating object using resolveNodes, how can we get the length of the object for calculating.

I used the objs.length but it is undefined. Here are the my script as example:

var objs = expenses.expensesWrapper.resolveNodes("expenseRow[*]");

xfa.host.messageBox(objs,"",0,0);

xfa.host.messageBox(objs.length,"",0,0);

var sum = 0.0;

for (var i = 0; i < objs.length; i++){

    sum += objs.item(i).total.rawValue;

}

expenses.total.subTotal.rawValue = sum;

1 Reply

Avatar

Level 1

OK, I found a resolve for this total calculation functionality in both PDF and HTML forms, I used the following scripts:

var len = expenses.expensesWrapper._expenseRow.count;

var sum = 0.0;

for (var i = 0; i < len; i++){

    sum += xfa.resolveNode("expenses.expensesWrapper.expenseRow[" + i + "].total").rawValue;

}

expenses.total.subTotal.rawValue = sum;