var transCount = 0;
function addTransaction() {
  transCount++;
  var tbody     = document.getElementById("transgrid").getElementsByTagName("tbody")[0];
  var row       = document.createElement("tr");

  var datecell  = document.createElement("td");
  var dateinput = document.createElement("input");
  dateinput.setAttribute("type", "text");
  dateinput.setAttribute("maxlength", "11");
  dateinput.setAttribute("name", "aM_transactionDateTime[" . transCount . "]");
  dateinput.setAttribute("class", "accountMinder_ShortText");
  datecell.appendChild(dateinput);

  var typecell  = document.createElement("td");
  // copy the original selectbox
  var sourcetypeinput = document.getElementByID("transtypeselect0");
  var typeinput = sourcetypeinput.cloneNode(true);
  // now change its name and id
  typeinput.setAttribute("name", "aM_transactionType[" . transCount . "]");
  typeinput.setAttribute("id", "transtypeselect" . transCount);
  typecell.appendChild(typeinput);

  var budgetcell = document.createElement("td");
  // copy the original selectbox
  var sourcebudgetinput = document.getElementByID("transbudgetselect0");
  var budgetinput = sourcebudgetinput.cloneNode(true);
  //now change its name and id
  budgetinput.setAttribute("name", "aM_transactionBudget[" . transCount . "]");
  budgetinput.setAttribute("id", "transbudgetselect" . transCount);
  budgetcell.appendChild(budgetinput);

  var checkcell  = document.createElement("td");
  var checkinput = document.createElement("input");
  checkinput.setAttribute("type", "text");
  checkinput.setAttribute("maxlength", "11");
  checkinput.setAttribute("name", "aM_transactionCheckNo[" . transCount . "]");
  checkinput.setAttribute("class", "accountMinder_ShortText");
  checkcell.appendChild(checkinput);

  var desccell  = document.createElement("td");
  var descinput = document.createElement("input");
  descinput.setAttribute("type", "text");
  descinput.setAttribute("maxlength", "255");
  descinput.setAttribute("name", "aM_transactionDescription[" . transCount . "]");
  descinput.setAttribute("class", "accountMinder_LongText");
  desccell.appendChild(descinput);

  var amtcell  = document.createElement("td");
  var amtinput = document.createElement("input");
  amtinput.setAttribute("type", "text");
  amtinput.setAttribute("maxlength", "12");
  amtinput.setAttribute("name", "aM_transactionAmt[" . transCount . "]");
  amtinput.setAttribute("class", "accountMinder_ShortText");
  amtcell.appendChild(amtinput);

  row.appendChild(datecell);
  row.appendChild(typecell);
  row.appendChild(checkcell);
  row.appendChild(desccell);
  row.appendChild(amtcell);

  tbody.appendChild(row);
}
