on 06-26-2008 1:13 PM
Hi,
I need to Calculate subtotals in adobeforms for quantity .Can anyone help me out with this?
My requirement is like this :
I have a field "kwmeng" for which i need to calculate the sum of kwmeng at the end of every page and need to sum up the totals of each page and print it on last page.
Can any1 provide me with the java script code to calculate the subtotal
Regards,
Nisrin.
Edited by: Nisrin Pindwarawal on Jul 1, 2008 3:30 PM
Edited by: Nisrin Pindwarawal on Jul 1, 2008 3:30 PM
Hello!
var i = 0
var p = $layout.page(ref($))
var d = 0
for i = 0 upto (page2.Table.Table2.BodyRow.all.length - 1) step 1 do
d = $layout.page(ref(page2.Table.Table2.BodyRow<i>.POSNUM))
if ( d == p ) then
page2.Table.Table2.PageTotal.PLACES = page2.Table.Table2.PageTotal.PLACES + page2.Table.Table2.BodyRow<i>.PLACES
page2.Table.Table2.PageTotal.BRGEW = page2.Table.Table2.PageTotal.BRGEW + page2.Table.Table2.BodyRow<i>.BRGEW
page2.Table.Table2.PageTotal.NETWR = page2.Table.Table2.PageTotal.NETWR + page2.Table.Table2.BodyRow<i>.NETWR
page2.Table.Table2.PageTotal.VAT = page2.Table.Table2.PageTotal.VAT + page2.Table.Table2.BodyRow<i>.VAT
page2.Table.Table2.PageTotal.WRBTR = page2.Table.Table2.PageTotal.WRBTR + page2.Table.Table2.BodyRow<i>.WRBTR
elseif ( d > p ) then
break
endif
endfor
Hope it will help You.
Good Luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Table data
For each row of the table we need to find a place for the field, which will be kept current page number.
In my case it will be called "MAGRV_PAGE"
For such fields we set a script:
Event: layout: ready
this.rawValue = xfa.layout.page(this)
Subtotal
Also, as for the rows of tables, it is necessary to find a place for the field, which will be kept current page number.
In my case it will be called "Page".
For such we fields set a script:
Event: layout: ready
this.rawValue = xfa.layout.page(this)
In line with subtotals place the following script:
Event: layout: ready
var len = BodyRow.all.length; var len = BodyRow.all.length;
WRBTR.rawValue = 0; WRBTR.rawValue = 0;
VAT.rawValue = 0; VAT.rawValue = 0;
NETWR.rawValue = 0; NETWR.rawValue = 0;
LFIMG.rawValue = 0; LFIMG.rawValue = 0;
for i=0 upto len - 1 step 1 do for i = 0 upto len - 1 step 1 do
if (Page.rawValue == BodyRow<i>.MAGRV_PAGE.rawValue) then if (Page.rawValue == BodyRow <i>. MAGRV_PAGE.rawValue) then
WRBTR.rawValue = WRBTR.rawValue + BodyRow<i>.WRBTR.rawValue; WRBTR.rawValue = WRBTR.rawValue + BodyRow <i>. WRBTR.rawValue;
VAT.rawValue = VAT.rawValue + BodyRow<i>.VAT.rawValue; VAT.rawValue = VAT.rawValue + BodyRow <i>. VAT.rawValue;
NETWR.rawValue = NETWR.rawValue + BodyRow<i>.NETWR.rawValue; NETWR.rawValue = NETWR.rawValue + BodyRow <i>. NETWR.rawValue;
LFIMG.rawValue = LFIMG.rawValue + BodyRow<i>.LFIMG.rawValue; LFIMG.rawValue = LFIMG.rawValue + BodyRow <i>. LFIMG.rawValue;
endif
endfor
WRBTR, VAT, NETWR, LFIMG - are fields that you want to summarize. In my example, the names of such fields are the same as the line names of the table.
Value WRBTR totals: WRBTR.rawValue
Value WRBTR <i> row of the table: BodyRow <i>.WRBTR.rawValue
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.