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

Changing names o fields when adding new row to a table

pogrom
Registered: May 4 2010
Posts: 10

I'm using the foloving script to add new rows to my tabl:

var nTableLength - Table1.nodes..length;
var nNumRow = 0;

Table1.Row1.instanceManager.addInstance(1);

It works fine however fields in the new row have the same names as fields in the irst row which causes problems later, when I use the generateg XML ti analyze

Could the script name the fields in new rows so that they are different from those in the first row? Like increasing a number or something?

jonom
Registered: Jan 31 2008
Posts: 133
When you create more instances of a row you should be getting an instance number that increments with each row. You can use that instance number to access specific fields.

Row1[0]
Row1[1]
Row1[2]
etc.

You can use a loop to walk through the instances to do what you want.

For instance, to create a field that totals the amounts in a field named "subtotal":
var fields = xfa.resolveNodes("Row1[*].SubTotal");var total = 0;for (var i=0; i <= fields.length-1; i++) {total = total + fields.item(i).rawValue;}this.rawValue = total;

It's even easier with FormCalc:
sum(Row1[*].SubTotal)
Hope that helps!