Loop through a table | Community
Skip to main content
Level 2
January 13, 2012
Solved

Loop through a table

  • January 13, 2012
  • 4 replies
  • 9133 views

Is it feasible to write code that loops through a table in a form? I'm currently writing separate sections of code for each row of a five-row table to validate data entries.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by _Bruce_Robertson

Hi,

It would be easier if your table contained one row that repeated with an initial count of five (this is set in the binding tab of the Object palette).  This will change the XML generated but assuming that is not a problem your could loop though your table with the code;

    var rows = this.resolveNodes("Table1.Row1[*]");

    for (var i=0; i<rows.length; i++)

  {

        var currentRow = rows.item(i);

        .

        .

        .

  }

If you do need the rows uniquely named then you could pass i and the result of "this.resolveNodes("Table1.Row"+i)" into a function.

This is you form back ... with only the first validation converted to the new approach.

https://acrobat.com/#d=akb0*Ptvdr3KSYN0VP*7zA

Hope this gets you started.

Regards

Bruce

4 replies

January 13, 2012

It actually depends on scenario....you need to post more details about your request and if possible share the form.....most codes segments are base on hierarchy and actions you would like to perform.

Level 2
January 13, 2012

Here's the form.

https://acrobat.com/#d=tc-tH46jIH8xx7i6pT60Rw

I was having issues with links earlier.

The validation occurs in the click event of btnSubmit.

_Bruce_Robertson
_Bruce_RobertsonAccepted solution
Level 10
January 14, 2012

Hi,

It would be easier if your table contained one row that repeated with an initial count of five (this is set in the binding tab of the Object palette).  This will change the XML generated but assuming that is not a problem your could loop though your table with the code;

    var rows = this.resolveNodes("Table1.Row1[*]");

    for (var i=0; i<rows.length; i++)

  {

        var currentRow = rows.item(i);

        .

        .

        .

  }

If you do need the rows uniquely named then you could pass i and the result of "this.resolveNodes("Table1.Row"+i)" into a function.

This is you form back ... with only the first validation converted to the new approach.

https://acrobat.com/#d=akb0*Ptvdr3KSYN0VP*7zA

Hope this gets you started.

Regards

Bruce

Level 2
January 17, 2012

That works for me. Thanks.