Javascript Confirm Delete

How to use a javascript confirm box to ask the user if they want to delete

<script>
function confirmDelete(deleleteUrl) {
if (confirm(“Are you sure you want to delete”)) {
document.location = deleleteUrl;
}
}
</script>

<a href=”javascript:confirmDelete(‘delete.php?id=1’)”>Delete</a>

Another way

<a href=”delete.php?id=1″ onclick=”return confirm(‘Are you sure you want to delete?’)”>Delete</a>

Leave a Comment

Your email address will not be published. Required fields are marked *