In an effort to string together cell info from multiple rows in a table, I'm wondering if it possible to use getElementById to accomplish this? My desired outcome of test code included is:
AAA1
BBB2
I am attempting to work my way to AAA1AAA2BBB1BBB2 string that will be passed in a hidden field to a third party package. The sample code works when I limit to one row but errors when I add the for loop.
Code:<html> <head> <script type="text/javascript"> function showRows() { for (iii=0;iii<=1;iii++) { var x=document.getElementById('myTable').rows[iii].cells; document.write(x[0].innerHTML); document.write("<br />"); } } </script> </head> <body> <table id="myTable" border="1"> <tr> <td>AAA1</td> <td>AAA2</td> </tr> <tr> <td>BBB1</td> <td>BBB2</td> </tr> </table> <br /> <input type="button" onclick="showRows()" value="Show rows in table"> </body> </html>



Reply With Quote

Bookmarks