Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Calculating total

Avatar

Former Community Member
I have a dynamic table that can add a new row when I push a button. And I want to display the total on a numeric field called TOTAL. This is the script that I put in TOTAL.



var jpt = xfa.form.er.BodyPage_1.Table.Table_invoice.resolveNodes("Row1[*]");



var sum = 0.0;

for (i = 0; i < jpt.length; i++)

sum += jpt.Row1(i).resolveNode("num_Total").rawValue;



this.rawValue = jpt.Row1(i).resolveNode("num_Total").rawValue;



When I run it from PDF Preview, it doesn't show me anything .. the TOTAL field is blank. Pls help me!!



Do I have to bind the field in the table to a data node? or use 'none' binding is OK. I am still new to livecycle and couldnt figure this out.
1 Reply

Avatar

Former Community Member
hi,




var jpt = xfa.form.er.BodyPage_1.Table.Table_invoice.resolveNodes("Row1[*]");



var sum = 0.0;

for (i = 0; i < jpt.length; i++) sum += jpt.Row1(i).resolveNode("num_Total").rawValue;



this.rawValue = jpt.Row1(i).resolveNode("num_Total").rawValue;




change the code as



var jpt = xfa.form.er.BodyPage_1.Table.Table_invoice.resolveNodes("Row1[*]");



var sum = 0.0;

for (i = 0; i < jpt.length; i++) sum +=

xfa.resolveNode("body.Table1.Row1["+i+"].num_Total").rawValue;



this.rawValue = sum;



Note : num_Total should be Numeric Field and You can set this in Object Pallete of the Field.