I created a system of alerts, where I intend to give the possibility to eliminate the alert if it is intended.
I have the following delete button and table:
<button type="button" name="Delete" Onclick="if(confirm('Tem certeza de que deseja excluir esta Mensagem?')) deletar();" class="btn btn-primary"><i class="glyphicon glyphicon-envelope"></i><i class="glyphicon glyphicon-remove-sign"></i></button>
<table class="table table-responsive table-striped table-bordered table-condensed table-hover">
<thead>
<tr>
<th>De</th>
<th>Assunto</th>
<th>Prioridade</th>
<th>Recebido</th>
</tr>
</thead>
<thead>
<tr>
<?php
do {
if ($nomede != $produto["De"]) {
?>
<th width="10%" colspan=4>Recebido: <?php echo $produto["Data"]; ?></th>
<?php
$nomede = $produto["De"];
}
?>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $produto["De"]; ?></td>
<td class="td-info view_data apagar" id="<?php echo $produto["Id"]; ?>,<?php echo $produto["Para"]; ?>" data-toggle="modal" href="#dataModal" width="20%" <?php echo $produto["Status"] != '0' ? ' style="font-weight:bold; font-size: 90%" ' : ' style="font-weight:normal; font-size: 90%" ' ?>><?php echo $produto["Assunto"]; ?></td>
<td><?php echo $produto["Prioridade"]; ?></td>
<td><?php echo $produto["Hora"]; ?></td>
</tr>
<?php } while ($produto = $resultado_cursos->fetch_assoc()); ?>
</tbody>
</table>
To delete I want to select the line, changing the color of the line when selecting and then delete, for this, I am doing the following:
jQuery:
function deletar() {
var ids = []; //arraypara armazenar os id's a serem deletados
$(".colorir").each(function() { //percorre todos os tr que possui a classe colorir
ids.push($(this).find(".apagar").attr("Id")); //adiciona o id da linha ao array
$(this).remove();
})
$.ajax({
url: './deletealerta',
type: 'POST',
cache: false,
data: {
ids: ids
},
error: function() {
},
success: function(result) {}
});
}
CSS:
.colorir {
background-color:#81BEF7;
}
The problem I have is that it does not select the row in the table to identify the id and be able to delete it by clicking the delete button. The only line you select is the line that separates by date as shown in the image:
But this line separating the date does not make sense to select because I can not delete it. I am not finding where I am to just select these date lines.
The problem is, since it does not select the line it does not return the line id for the function to be able to delete the line. But I do not know how to solve the problem.