JavaScript Confirm before deletion with PHP/MYSQL

bingwa picture bingwa · Apr 20, 2013 · Viewed 63.4k times · Source

I have tried a number of examples here but I can get my code to actually show a popup window before deletion. The code I use can be found here:

echo "<td><button class='btn'><a href=\"deleteuserExecute2.php?login=" .$login. "\" onClick=\"return confirm(\'Delete this Account?\')\"; >DELETE ACCOUNT </a></button></td>";

http://jsfiddle.net/mpogoro/EGfcY/

Answer

Samuel Cook picture Samuel Cook · Apr 20, 2013

You just need to use the onclick method for your link or button:

<a href="DELETE_PAGE" onClick="return confirm('Delete This account?')">Delete Account</a>