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

Subtotal per page

awe
Registered: Aug 27 2008
Posts: 4

Hi all,

I have a multipage document which holds a table (array) with invoice details. My requirement is to sum up the values per page and print them at the end of each page and the beginning of the next.

I tried two different approches: I determine the number of rows printed so far, add them up and output them during the Layout:Ready event (Code A). The other is to parse the document for all fieds (including the table fields?!) and sum up the values containing the field name - which is KZWI2 (Code B) also at the same event.

Unfortunately both of them do not work: the first would work if I could determine how many rows were already output (tried it with hardcoding it with value 8). The value for this.parent.index is always 0 thus summing up the first line of my table. For the other I doubt that the table fields are taken into account.

Everything is in Javascript and I can not debug it :-(

Any idea to get either approach working or any other suggestion to reach the goal would be greatly appreciated!

Cheers,
Axel

Code A:

var tableIndex = this.parent.index
var subTotal1
var subTotal2

for i=0 upto tableIndex do
subTotal1 = sum(data.BODY.ITEM_DETAIL.DATA_DETAIL[i].DETAILS.MATERIAL.KZWI2[*])
subTotal2 = sum(subTotal1, subTotal2)
endfor
sum(subTotal2)

Code B:

var fields = xfa.layout.pageContent(0 , "field", 1);
var total = 0;
for (var i=0; i <= fields.length-1; i++){
if (fields.item(i).name.match(/KZWI2/gi)) {
total = total + fields.item(i).rawValue;
}
}
this.rawValue = total;

My Product Information:
LiveCycle Designer, Windows
formman
Registered: Jul 17 2008
Posts: 44
awe,

Here is how I would do it:


var oNodes = Page1.nodes;
//Page1 is the name of the subform. You could use this.parent.nodes
//as well to be generic.
var oNodesLength = oNodes.length;
var total = 0;
for (var i=0; i < oNodesLength; i++)
{
if (oNodes.item(i).name.match(/KZWI2/gi));
{
total = total + oNodes.item(i).rawValue;
}
}
this.rawValue = total

See if that works.

Rick Kuhlmann
Tech-Pro

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN

formman
Registered: Jul 17 2008
Posts: 44
awe,

I am sorry I did not read you issue fully. If you would e-mail me I will gladly send you a sample form that should solve your problem.

formman [at] ix [dot] netcom [dot] comRick Kuhlmann

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN