I'm creating a function to save a form directly to a table, the table rows contain an onclick function that takes the function in javascript
function xpto() {
if (linha == null) {
var linha1 = document.getElementById("tabela").insertRow(-1);
linha1.insertCell(0).innerHTML = document.getElementById("oT").value;
linha1.insertCell(1).innerHTML = document.getElementById("tColeta").value;
linha1.insertCell(2).innerHTML = document.getElementById("tEntrega").value;
linha1.insertCell(3).innerHTML = document.getElementById("pEntrega").value;
linha1.insertCell(4).innerHTML = document.getElementById("trans").value;
linha1.insertCell(5).innerHTML = document.getElementById("mod").value;
} else {
linha.cells[0].innerHTML = document.getElementById("oT").value;
linha.cells[1].innerHTML = document.getElementById("tColeta").value;
linha.cells[2].innerHTML = document.getElementById("tEntrega").value;
linha.cells[3].innerHTML = document.getElementById("pEntrega").value;
linha.cells[4].innerHTML = document.getElementById("trans").value;
linha.cells[5].innerHTML = document.getElementById("mod").value;
}
linha = null;
mostrarTabela();
}
How do I insert attributes in the new line created by the save option, in case I have to insert the html effect onclick="editar(this)";
var linha1 = document.getElementById("tabela").insertRow (-1);