Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Loop through table (beginner question)

Avatar

Former Community Member

Hello,

I been reading and reading but can´t seem to do what I want to do.

I do a lot of forms in Livecycle but can´t seem to understand even the most easy loop.

Lets say I have a table with two columns and ten rows. Textfields in column A is called Cell1 and in column B Cell2.

I want to look through all the rows for this:

If(Cell1.rawValue !== null)

Cell2.fontColor = "255,0,0";

else

Cell2.fontColor = "0,0,0";

If anyone can help me with this I would be very happy. Mayvbe I can start to understand this since it seems like I´m missing out on some very handy functions,.

/ Anders

Sweden

1 Accepted Solution

Avatar

Correct answer by
Level 8

Assuming all your rows are named 'Row':

for (var a=0;a<Row.all.length;a++){
      if (Row.all.item(a).Cell1.rawValue!==null)
           Row.all.item(a).Cell2.fontColor = "255,0,0";
      else
           Row.all.item(a).Cell2.fontColor = "0,0,0";
}

Kyle

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

Assuming all your rows are named 'Row':

for (var a=0;a<Row.all.length;a++){
      if (Row.all.item(a).Cell1.rawValue!==null)
           Row.all.item(a).Cell2.fontColor = "255,0,0";
      else
           Row.all.item(a).Cell2.fontColor = "0,0,0";
}

Kyle

Avatar

Former Community Member

Thank you so much

And if I would like to limit the loop I write as follows?

for (var a=0;a<10;a++){    

  if (Row.item(a).Cell1.rawValue!==null)       

    Row.item(a).Cell2.fontColor = "255,0,0";    

  else          

Row.item(a).Cell2.fontColor = "0,0,0"; }

Thanks again.

/ Anders

Sweden