0
Follow 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 on the table. For this reason I put this check at the end. The table is also generated dynamically. Follows 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 it could be on account of your daughters, so I’m deleting both. Some dirt?
First of all, the id should start with a letter, then you can use the number you want, but it can’t just be a number. Make this adjustment and see if it resolves, if not resolved, we proceed
– Bruno Rigolon
Hello @Brunorigolon, I set this but it hasn’t worked yet.
– Matheus Delatorrre