Here is my javascript function that should permanently delete a line:
function deletaItemExtra(item){
var x = document.getElementById(item);
x.deleteCell(1);
x.deleteCell(0);
document.getElementById(item).deleteRow;
if(document.getElementById(item) != null){
alert('Ainda é encontrado no sistema');
}else{
alert('Foi totalmente deletado do sistema');
}
}
The problem is that when I check the lines, which should have been deleted, it is still in the table. For this reason I put this check at the end. The table is also generated dynamically. Here is the code:
var itemExtra = itemExtra.split("|");
var idExiste = false;
var id = 0;
while(idExiste == false){
id = Math.floor((Math.random() * 10000) + 1) + '_' + itemExtra[0].replace(' ', '');
if(document.getElementById(id) == null){
idExiste = true;
}
}
var table = document.getElementById(tabela);
var row = table.insertRow(0);
row.id = id;
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = itemExtra[1];
var deletaExtra = document.createElement("INPUT");
deletaExtra.setAttribute("type", "button");
deletaExtra.addEventListener("click", function(){
deletaItemExtra(id.replace(" ",""));
});
deletaExtra.setAttribute("value", 'X');
cell2.appendChild(deletaExtra);
I searched and in some places said that it could be on account of the daughters, so I'm deleting the two. Any issues?