Welcome to the ninth part of a thirteen-part series on HTML database forms. In the previous part we began our discussion of Tabular forms, having dealt with Single-Row forms up until that point. In this part we continue our discussion of what functions to use with Tabular forms and how they are different from their Single-Row counterparts.
Tabular Database Form Functions with HTML - The editRow() Function (Page 2 of 5 )
This function is different from the one for the Single-Row Form, just as the addRow() function here is different from that of the corresponding one in the Single-Row Form, and for similar reasons. When you click the Edit button, it is the active (selected) row that will be edited. The editRow() function begins by checking to see if there is an active row (selected row). For our tabular form, when the web page opens the index variable is set to null. The editRow() function checks to see if the index is null. If it is, it means that no row has been selected.
It then alerts the user that he must select the row he wants to edit and returns after the user clicks the OK button of the alert box. If a row has been selected, the function sets the editMode variable to "true" and then disables all the buttons. It makes the selected row writable by calling the makeWriteInputControls() function which now receives the index as an argument. Finally it displays the conspicuous button, which has the text "After Editing or Adding, You must Click here." The function is:
function editRow()
{
//you must select a row before you can edit, this means the index variable must hold an integer