1
I created a warning system, where I want to give the possibility to delete the alert if desired.
I have the following table and delete button:
<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 you to select the line, changing the color of the line when selecting to then delete, for this I am doing as follows:
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 can delete 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 that does date separation doesn’t even make sense to select because I can’t delete it. I’m not finding the problem
Hello friend. Add php tag please.
– Maury Developer
Bruno, can you put in the question the javascript code that makes mark the line? I didn’t find this nor an event in html tbm
– Ricardo Pontual
Puts a
checkbox
on each line and then takes only the values of the lines that are with thecheckbox
marked.– fernandoandrade
Javascript is case sensitive, wrong: Onclick || correct: onclick, I’m checking the rest of the code
– Wilson Rosa Gomes