Show table_edit.html syntax highlighted
<html>
<body>
<script language = javascript>
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtRow' + iteration);
el.setAttribute('size', '40');
cellRight.appendChild(el);
}
function removeRowFromTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(2);
}
</script>
<form action="tableaddrow_nw.html" method="get">
<input type="button" value="Add" onclick="addRowToTable();" />
<input type="button" value="Remove" onclick="removeRowFromTable();" />
<table border="1" style="table-layout: fixed; width: 100%;" id="tblSample">
<tr>
<td style="width: 100px;">1</td>
<td style="overflow: hidden;"><DIV style="display:block; width:1000px;">This is some texThis is some texThis is some texThis is some texThis is some texThis is some text</DIV></td>
<td style="width: 100px; background:gray;">1/1/2005</td>
</tr>
</table>
</form>
</body>
</html>
See more files for this project here