Reputation: 434
I'm wanting to make a confirmation popup for when I click to delete an id from a database which either continues running the script and deletes the id (YES) or cancels the script and goes back (NO).
I need solution in JavaScript and PHP.
Here Is My Code Link. Please check and give me solution
https://drive.google.com/drive/folders/0B2lSiCcdmUf-WDM3SWQzc29sdGM?usp=sharing
Upvotes: 0
Views: 2555
Reputation: 11
You can use jQuery UI for confirmation dialog. Don't use javascript confirmation alert you can't design it. So better is use jQuery UI you can design it base on you site theme. See this link you can understand source code easily.
Upvotes: 1
Reputation: 80
https://lipis.github.io/bootstrap-sweetalert/
for more beautiful alerts
<script>
$(document).ready(function(){
$("p").click(function(){
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});
});
</script>
Upvotes: -1
Reputation: 3234
I hope you have created a file to delete specific record. In the anchor tag just pass the url to that file with specific record id. Add onclick to a tag to prompt a confirmation.
<a href="DELETE_PAGE_URL?id=record_id" onclick="return confirm('Are you sure?')" >Delete Record</a>
For more detail Javascript Confirm()
If you need further assistance there are lots of php CRUD tutorial on the web. PHP CRUD TUTORIAL
Hope it will help
Upvotes: 1
Reputation: 6311
Write a on click function
<input type="button" Onclick="delete()">
function delete(){
var result = confirm("Are you want to delete");
if (result) {
//delete the item
}
}
Upvotes: 1
Reputation: 15
Only Javascript is here of sense
var r = confirm("You want to delete an user! are you sure?");
if (r == true) {
// request php script on server to delete an id
} else {
// you do nothing here
}
Upvotes: 1