
function addRowToTable()
{
  var tbl = document.getElementById('listing');
  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 el = document.createElement('input');
  el.type = 'text';
  el.name = 'new_name_' + iteration;
  el.id = 'new_name_' + iteration;
  cellLeft.appendChild(el);
  
  // right cell
  var cellRight = row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'new_address_' + iteration;
  el.id = 'new_address_' + iteration;
  cellRight.appendChild(el);
  
}

function removeRowFromTable()
{
  var tbl = document.getElementById('listing');
  var lastRow = tbl.rows.length;
  if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}

