260Part IIIDocument Objects ReferenceListing 15-18(continued) function addRow(item1) (Web server) {

260Part IIIDocument Objects ReferenceListing 15-18(continued) function addRow(item1) { if (item1) { // assign long reference to shorter var namevar theTable = document.getElementById( myTable ); // append new row to the end of the tablevar newRow = theTable.insertRow(theTable.rows.length); // give the row its own IDnewRow.id = newRow.uniqueID; // declare cell variablevar newCell; // an inserted row has no cells, so insert the cellsnewCell = newRow.insertCell(0); // give this cell its own idnewCell.id = newCell.uniqueID; // display the row s id as the cell textnewCell.innerText = newRow.id; newCell.bgColor = yellow // re-use cell var for second cell insertionnewCell = newRow.insertCell(1); newCell.id = newCell.uniqueID; newCell.innerText = item1; } }

Row ID Data
firstDataRow Fred
secondDataRow Jane


Enter text to be added to the table:

Related Items:idproperty; getElementById()method. elementObject.uniqueID