<script>
function addRowToTable()
{
var tbl = document.getElementById('datatable');
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);
// Number Cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
//cellLeft.setAttribute('bgColor', '#CCCCCC');
cellLeft.setAttribute('align', 'center');
cellLeft.appendChild(textNode);
// P/N Cell
var cellRight1 = row.insertCell(1);
var el = document.createElement('input');
//cellRight1.setAttribute('align', 'center');
//cellRight1.setAttribute('bgColor', '#CCCCCC');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtPartNumber' + iteration);
el.setAttribute('id', 'txtPartNumber' + iteration);
el.setAttribute('size', '30');
cellRight1.appendChild(el);
function removeRowFromTable()
{
var tbl = document.getElementById('datatable');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
</script>
Tag : PHP, MySQL, Ms SQL Server 2005, Ms SQL Server 2008, CakePHP