In this Form:
<input type="checkbox" value="1" data-id=1" name="status_entrega" id="status_entrega">
<div id="retorno_1" style="display:none; float:left">Atualizado</div>
<input type="checkbox" value="1" data-id=2" name="status_entrega" id="status_entrega">
<div id="retorno_2" style="display:none; float:left">Atualizado</div>
I have the following jQuery:
$('#status_entrega').click(function(){
var id_pedido = $("#status_entrega").attr("data-id");
$("#retorno_"+id_pedido).toggle(this.checked);
});
However, the first item I can mark as checked, the second and the others, I can not even mark ... Does not return the update message. Can anyone help?
Update:
According to Sergio's help, I modified it, but I need you to uncheck the update request as well. Here is the updated code:
$('[name="status_entrega"]').click(function() {
var id_pedido = $(this).attr("data-id");
$("#retorno_" + id_pedido).toggle(this.checked);
$.ajax({
type: 'post',
url: '../ajax/getTransacaoOK',
success: function (response) {
$("#retorno_" + id_pedido).html("Atualizando...");
setTimeout(function(){
$("#retorno_" + id_pedido).html("Atualizado!");
setTimeout(function(){
$("#retorno_" + id_pedido).html("");
},1000);
},2000);
},
});
});