When you query a database, the result you receive is a recordset. The form in which your result can be presented is affected by the capabilities of the language you use. This can present a challenge for certain languages. This article presents one way to meet that challenge if you program for the web.
Using the HTML Table Element as a Recordset - Add a Row (Page 5 of 5 )
You add (insert) a row using a row index. If you add (insert) a row with index 3, the row which had the index 3 will now have the index 4. When you add a row, it pushes the row which was at its position, and the rows below that one, one step downward. The following statement would add a row with the index value of i.
Notice the method “insertRow(i)” at the end. When you add a row, the row is empty, that is, it does not have a cell. You then have to add (insert) cells in the row. The following statement will add (insert) a cell in the row whose index value is i, and at a position where the cell (column) index is j.
This function takes, as arguments, the row index and the number of cells (noColms -- for number of columns). It produces the row and then the “for” loop produces the cells.
Conclusion
Any good container can be used as a recordset. The HTML table element can be used as a recordset in a web page. With the value of “none” for the CSS display property, you do not see the recordset. With the value of “block” for the CSS display property, you see the recordset. The DOM allows us to use the HTML table as a recordset.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.