Looping through cell in table | Community
Skip to main content
Level 4
November 19, 2015
Solved

Looping through cell in table

  • November 19, 2015
  • 12 replies
  • 9117 views

Hi all!

I have been digging but can't find my answer.  I have a table that you can add rows to.  In the same cell in each row I have to validate if the number in the field starts with a 4 or 5 ( the number is a total of 6 digits long).  I have java script that validates the 4 or 5.  but I need to loop through all the rows for that cell. Right now just validates on the first row.

Help!

Thank you!

Jodi

var Grant = Main.PreApproved.Table1.Row1.Fund.rawValue

var GrantFund = Grant.charAt(0)


if  (GrantFund == 4 || GrantFund == 5).......

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,

If you table has only one Row object that repeats (as opposed to a Row1, Row2, ...) you should be able to use;

 

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

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

    var row = rows.item(i);

    var GrantFund = row.Fund.isNull ? 0 : row.Fund.rawValue.charAt(0);

    if  (GrantFund == 4 || GrantFund == 5) {

        //...

    }

}

 

Regards

Bruce

12 replies

Jodi1725Author
Level 4
January 31, 2018

Hey Bruce!

Long time no talk! Hope you are doing well!  I have another repeating issue that I can't get to work

I once again am trying to validate through a repeating subform, but this is just the subform.  I have tried to manipulate the different code you sent me but I am just getting validation on the first subform not the repeated ones.  What am I missing?
Thank you for all your help!

Jodi

Gift Transmital Form_2.pdf - Google Drive

Jodi1725Author
Level 4
January 31, 2018

Hey Bruce!

I actually figured it out!  I used Loop Through Subform Instances  and used this code.

expenseReport.#subform[0].validate2::click – (JavaScript, client) 
var vItems = expenses.expense.all; 
for(i=0; i<vItems.length; i++) 

    if (vItems.item(i).description.rawValue == null) 
    { 
        xfa.host.messageBox("Missing description field"); 
        break; 
    } 

}

Took me a few tries to get it to work but it did Thanks!

Jodi