Generally When you perform the CRUD operations on any application . To warn a user when user trying to remove / delete anything from the displayed data from the database.
I.e " Are you sure you want to delete this item ? ".
When user click on the remove link it will pop up the confirm message . Here user press on the ok key then that item will be removed otherwise nothing will happen.
This can be done in two different ways
JavaScript Function
Delete
I.e " Are you sure you want to delete this item ? ".
When user click on the remove link it will pop up the confirm message . Here user press on the ok key then that item will be removed otherwise nothing will happen.
This can be done in two different ways
- You can create the JavaScript function and call this function from the anchor href tag
- You can directly call the confirm function from the on click event.
JavaScript Function
<script> function confirmDelete(delUrl) { if (confirm("Are you sure you want to delete this item")) { document.location = delUrl; } } </script>Function calling
<a href="javascript:confirmDelete('delete.php?id=1')">Delete</a>Second way
<a href="delete.php?id=1" onclick="return confirm('Are you sure you want to delete this item ?')">Delete</a>Output
* If you like this post please don’t forget to subscribe Techies Badi - programming blog for more useful stuff
EmoticonEmoticon