// mredkj.com
// 2005-11-17
function appendRow(tblStr)
{
  var tbl = document.getElementById(tblStr);
  var row = tbl.insertRow(tbl.rows.length);
  
  // text cell
  var cellText = row.insertCell(0);
  var textNode = document.createTextNode(tbl.rows.length - 1);
  cellText.appendChild(textNode);
  
  // input text cell
  var cellInputText = row.insertCell(1);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('size', '40');
  el.setAttribute('value', 't' + (tbl.rows.length - 1));
  cellInputText.appendChild(el);
  
  // select cell
  var cellSel = row.insertCell(2);
  var sel = document.createElement('select');
  sel.options[0] = new Option('option zero', 'value0');
  sel.options[1] = new Option('option one', 'value1');
  cellSel.appendChild(sel);
}

function deleteLastRow(tblName)
{
  var tbl = document.getElementById(tblName);
  if (tbl.rows.length > 2) tbl.deleteRow(tbl.rows.length - 1);
}

function getCells(tblStr, o0, o1, o2)
{
  var tbl = document.getElementById(tblStr);
  var outTxt0 = document.getElementById(o0);
  var outTxt1 = document.getElementById(o1);
  var outTxt2 = document.getElementById(o2);
  var lastRow = tbl.rows.length - 1;
  outTxt0.value = tbl.rows[lastRow].cells[0].innerHTML;
  outTxt1.value = tbl.rows[lastRow].cells[1].firstChild.value;
  outTxt2.value = tbl.rows[lastRow].cells[2].firstChild[tbl.rows[lastRow].cells[2].firstChild.selectedIndex].text;
}