When will you click on delete recorded, after then will open dialog box and will ask you, are you sure delete this record. that time this tutorial help you.

This is a way of ensuring that items are not accidentally deleted, or the wrong item deleted by mistake. When clicked on the link, then open confirmation box. if the user selects 'ok' then delete is done. if the user selects on 'no' or 'cancel' then not delete records..

See below example

// first example

<a href="delete.php?delete_id=<?php echo $row['id'];?>"  onclick="return confirm('Are you sure you want to delete this item?');">Delete</a> 


// second example

<a href="delete.php?delete_id=<?php echo $row['id'];?>" class="delete" data-confirm="Are you sure to delete this item?">Delete</a>

$('.delete').on("click", function (e) {
    e.preventDefault();

    var choice = confirm($(this).attr('data-confirm'));

    if (choice) {
        window.location.href = $(this).attr('href');
    }
});
Connect With Facebook