Expand my Community achievements bar.

SOLVED

Calculating error, need some help.

Avatar

Level 1

I am currently working on an order form that has multiple items, each in their own sub form.  I am using the following script in the layout:ready function on my total box.  The problem I am having is it is only adding up the totals from the first page of the form, and not recognizing the totals from the second page of the form.  any help would be great, thanks!

var

fields = xfa.layout.pageContent(0 , "field", 0);

var

total = 0;

for

(var i=0; i <= fields.length-1; i++) {

if

(fields.item(i).name == "p1") {

total

= total + fields.item(i).rawValue;

}

}

this.rawValue

= total;

 

Thanks,Aaron

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can try the following code and let me know if you still have issues..


var total = 0;

// Get the field containers from each page.
for (var i = 0; i < xfa.layout.absPageCount(); i++) {
var oFields = xfa.layout.pageContent(i, "field");
        var nodesLength = oFields.length;
       
// Get fields in the selected page.
        for (var j = 0; j < nodesLength; j++) {
  var oItem = oFields.item(j);
  if(oItem.name == "p1")
   total = total + oItem.rawValue;
}
}

this.rawValue = total;

Thanks

Srini

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

You can try the following code and let me know if you still have issues..


var total = 0;

// Get the field containers from each page.
for (var i = 0; i < xfa.layout.absPageCount(); i++) {
var oFields = xfa.layout.pageContent(i, "field");
        var nodesLength = oFields.length;
       
// Get fields in the selected page.
        for (var j = 0; j < nodesLength; j++) {
  var oItem = oFields.item(j);
  if(oItem.name == "p1")
   total = total + oItem.rawValue;
}
}

this.rawValue = total;

Thanks

Srini

Avatar

Level 1

Thanks Srini, that worked perfectly!

Aaron