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