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 deleteRow() Function (Page 4 of 5 )
This function first of all checks to see if a row has been selected, just as the editRow() Function did. It also has to take into consideration that the recordset now has Input Text Controls for each visible cell. This is the function:
function deleteRow()
{
//you must select a row before you can delete, this means the index variable must hold an integer
if (index == null)
{
alert('You must select the row to delete.');
return;
}
//add the row to be deleted with its indication to the Transmitted Table.
includeInTransmittedTable('DELETED');
//replace the first six fields of the recordset row and all control fields with the word, DELETED
for (j=0;j<6;j++)
{
//form the input text control ID
CID = "EI" + index + j;
document.getElementById(CID).value = "DELETED";
}
}
The sort() Function
For the Single-Row Form, the sort() function had the line "showFirstRow()." Here there are no navigation buttons, so this line is not necessary. This is the new sort() function:
function sort()
{
//display a dialog box that prompts the user for input of title - Name is default
var title = prompt("Enter the Title of the Column for Sorting", "Name");
if ((title != null)&&(title != ""))
{
var titleInx = getColumnIndex(title); //the cell index of the recordset
if (titleInx == 6)
{
alert('The title does not exist or you typed it wrongly - type with the right case.');
return;
}
quickSort("0", (numberOfRows - 1), titleInx);
}
setTitleBool(title); //indicate in the titleBoolArr array that the column with the title is sorted