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

What script works in a dynamic form that uses nested tables for multiple categories or sections?

Avatar

Level 1

I have developed a dynamic form in which the user can add categories and items to a bid proposal form. I have been successful at getting the item amounts to calculate and the subtotals to calculate but unsuccessful with any script that will result in the sum of all the subtotals. I am not a programmer and I am just learning formcalc and javascript. I would be very grateful if the experts on this forum could help me. Below is some of the scripts that I have tried and a screen capture of the form hierarchy:

Example 1:

// Access a field in a repeating subform by looping through the node list.

var oFields = xfa.resolveNodes("ItemCategories[*].SubTotal");

var nNodesLength = oFields.length;

var nSum = 0;

for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {

nSum += oFields.item(nNodeCount).rawValue;

}

TotalBid.rawValue = nSum;

Example 2:

var c = this.getField("Category");

   var a = c.getArray();

    var sum = 0;

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

var f = this.getField("SubTotal");

   var b = f.getArray();

    var sum = 0;

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

    sum += b[i].value;

if (sum !=0)

    event.value = sum;

else

event.value = "";

Image1.jpg

3 Replies

Avatar

Level 10

FormCalc uses less coding than Java Script on the calculations. also the processing time also will be less.

If you can send the form to LiveCycle9@gmail.com then I can send you back the form with the script in it.

Thanks

Srini

Avatar

Level 1

I will be out of the office starting 07/20/2010 and will not return until

07/26/2010.

I will respond to your message when I return.

Avatar

Level 1

Thank you Srini!

The solution was simpler than I ever thought.

This forum is awesome!

Below is the magic script that works in my form:

Sum(form1.BidForm.Table1.Categories[*].ItemCategories.Table2.FooterRow.SubTotal);