var nextRowId=1; function getNextRowId() { return nextRowId; } function renumberTableRows(){ var row_no=1; var table = document.getElementById("tabbody"); for (var i = 0, row; row = table.rows[i]; i++) { // row.cells[0].innerHTML=row_no++; } } function deleteTableRow(rowId){ alert (rowId); var target = document.getElementById("upload-target"+rowId); var children = target.children; // delete all uploaded elements for (var i = 0; i < children.length; i++) { var tmp = children[i].getAttribute("data-id"); $K.ajax.post({ url: 'delete.php', data: 'id='+tmp, before: function(xhr) {}, success: function(response) {}, error: function(response) {} }); } // delete the row from table var element = document.getElementById("trow"+rowId); element.parentNode.removeChild(element); renumberTableRows(); // alert(rowId); } function addTableRow(){ var $node = $K.dom('#tabbody'); // create a new table row with id var element = document.createElement('tr'); element.setAttribute("id", "trow"+nextRowId); var a_type = document.getElementById("a_type").value; var a_date = document.getElementById("a_date").value; var a_description = document.getElementById("a_description").value; var a_amount = document.getElementById("a_amount").value; var a_currency = document.getElementById("a_currency").value; /* a_type = "Hello";*/ var e=""; // add column for position no e += `