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

Grand Total Script

prespares
Registered: Nov 6 2008
Posts: 47
Answered

Hello,

I used Thom Parker's scripting for Programming List and Combo fields in Acrobat and LiveCycle forms and had great success. I have now added a Grand Total field to sum all the values of each dynamic row. Here's my script for the grand total numeric field-calculate event-Javascript:

// Acquire all "Amount" Fields there are inside a subform named "OrderItems"
var flds = xfa.form.TopmostSubform.resolveNodes("$form..OrderItems[*].Total");

// Loop over list of fields and add up values
var sum = 0;
for(var i=0;i

My Product Information:
LiveCycle Designer, Windows
madhu_livecycle
Registered: Jun 23 2009
Posts: 13
Hi prespares,

for your grand total field, place the below script in "Calculate" Event of the Field with Language as "Formcalc"

Sum(detail[*].numAmount)


Note: replace the detail with your Table Row name and
numAmount with the amount field name in your table row.


Thanks,
Madhu.
prespares
Registered: Nov 6 2008
Posts: 47
Thank you. That worked great!
prespares
Registered: Nov 6 2008
Posts: 47
Hi Everyone,

Is it possible to use this script in relation to the value in a drop down?

for instance I have two calculations:

1). For cost per lead, where the amount would be the standard "Sum(detail[*].numAmount)"
2). For cost per thousand, where the amount would be divided by 1000.


I was wondering if I could add some scripting that would make the formula "Sum(detail[*].numAmount)" conditional on the binding of the drop down.

Is this possible?

Joe
madhu_livecycle
Registered: Jun 23 2009
Posts: 13
Hi prespares,

for example your dropdown name is 'D1' with two entries "For cost per lead" and "For cost per thousand"

replace the script which you are using now i.e. "Sum(detail[*].numAmount)" with the below script

Script Language : FormCalc Event: Calculate

if ( D1 == "For cost per lead" )
then
Sum(Amount[*])
elseif ( D1 == "For cost per thousand" )
then
Sum(Amount[*])/1000
endif