Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

Formcalc to JavaScript


Not applicable

I have an invoice form which has fields for InvoiceLineTotal and at the end InvoiceTotal. I got the form working so that LineTotals are calculated (quantity*unitprice) and now I want to make the Invoice total calculation automatic.

I managed to do so with formcalc but as follows:


But all the other scripts in the form are JavaScript so I would prefer to use JavaScript to this calculation too. The problem is that I just can't get this damn thing to work. Has anyone written a general function in JavaScript which would work like FormCalc sum function?


1 Reply


Not applicable
Kari,<br /><br />Click on the link below to see an example that is done in javascript to calculate the sum.<br /><br /><br /><br />The javascript is on the total field on the 'calculate' event.<br /><br />var nTotal = 0; <br />var oAmountFlds = xfa.resolveNodes("xfa.form.form1.page1.Amount[*]"); <br /><br />for( var i=0; i<oAmountFlds.length; i++) <br />{ <br /> if (oAmountFlds.item(i).rawValue != null) <br /> { <br /> nTotal += parseFloat(oAmountFlds.item(i).rawValue); <br /> } <br />} <br />this.rawValue = nTotal;


Level 3


Any chance that you could post this example pdf again?

I need to turn my FormCalc sum for a repeatable table into a javascript sum express because of some additional conditions that I had to include in the calculate field.




Not applicable
Thank you!

Copied, pasted and modified - Works like a charm!

Actually I had similar loop solution in my mind, but I didn't get the reference to the actual lineAmount formfield to work.

Now I (in fact the whole forum) have a good, clear example on this too.

But thanks again, this was a big help to me