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 - Minimum Requirements of a Read/Write Recordset (Page 2 of 5 )
A recordset should have at least the following functions:
A function to give the total number of rows of the recordset.
A function to locate a row or cell in order to access data.
A function to edit data in a row.
A function to delete a row.
A function to add a row.
The HTML TABLE as a Container
The DOM gives the HTML table properties and methods to access the cell data, rows and columns. It is because of the DOM that we can use the HTML TABLE as a container. Features of the HTML DOM Table Object we shall use are as follows:
Table Object Collections
cells[]: Returns an array containing each cell in a table.
rows[]: Returns an array containing each row in a table.
Table Object Methods
insertRow(): Inserts a new row in a table.
deleteRow(): Deletes a row from a table.
Features of the HTML DOM TableRow Object we shall use are as follows:
TableRow Object Collections
cells[]: Returns an array containing each cell in the table row.
TableRow Object Methods
insertCell(): Inserts a cell in a table row.
TableCell Object Properties
InnerHTML: Sets or returns the HTML (cell content) between the start and end tags of a table cell.
We shall use the following data (employee table of a company) in our illustrations: