Custom Web Applications to Grow Your Business

(256) 429-8145

How to add javascript confirmation prompt to delete button in php

If you have created back-end for your clients to add, edit and delete content it would be prudent to add a confirmation prompt. This will ask the editor whether or not he/ she is serious about deleted the mysql row. This is used as a precaution as the editor could click on the delete button by mistake and erase value data. So here it is Place this in the head section of the page that list the articles for edit or delete <script> function de_confirm() { return confirm('Are you sure?'); } </script> Use this code below for you delete link or button echo "<a onclick='return de_confirm();' href='delete.php?id=".$id." onclick='return confirm(\'Are you sure of delete?\');' '>Delete</a>"; If there is a a better way to set the confirmation prompt, I would love to hear from you