Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Filling in a table using scripts

Avatar

Former Community Member
I would like to know how it is possible to fill in a table using JavaScript. The table has varying rows and the data is based on certain field values. Since the table rows would all have the same name, I have been trying to use the resolveNode function but with no success.



Thanks
1 Reply

Avatar

Former Community Member
Hello Daniel,<br /><br />Here is a little example showing how to assign values to table rows<br /><br />var tableRows=Table1.resolveNodes("row[*]");//get all rows in table<br />var rowsLn=tableRows.length;//get the number of rows<br />for (var i=0;i<rowsLn;i++){//cycle through rows<br /> tableRows.item(i).Cell1.rawValue=i;<br /> tableRows.item(i).Cell2.rawValue=i+5;<br /> tableRows.item(i).Cell3.rawValue="text"+i<br />}<br /><br />Hope it should help.