0
Guys, I have a delete button that has a href directed to the php delete file. I would like to display a confirmation message before sending the registration to the exclusion page. I used the confirm() method of the java script to bar href from the link and it worked, but I wanted to display a more customized message and to do so, I used a Java framework called sweetAlert. Through the onclick function in the link, I call the confirmation message function, and in the function, if the option is true, I send via window.location.href to the delete php file. My question: Since these are records coming through a while loop directly from the database, how can I send the registry ID for the function responsible for the confirmation message? Since the registry identifier code (pk) is in a php variable and the function is js. Follows the code:
//código do link
<a onclick="confirma_excluir_cliente('');" href="exclui_cliente.php?codigo=<?=$linha['codigo']?>" class="btn btn-danger"><i class="fa fa-trash"></i></a>
//funcao da mensagem
var confirma_excluir_cliente = function(){
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false,
},
function(isConfirm){
if (isConfirm) {
window.location.href="exclui_cliente.php"
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
thanks in advance
Ricardo, thank you so much for answering, it worked! ;)
– Matheus Minguini