Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Confirm before deletion with PHP/MYSQL [closed]

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/

like image 250
bingwa Avatar asked Apr 20 '13 14:04

bingwa


2 Answers

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>
like image 133
Samuel Cook Avatar answered Sep 21 '22 22:09

Samuel Cook


  <script type="text/javascript">
      function ConfirmDelete()
      {
            if (confirm("Delete Account?"))
                 location.href='linktoaccountdeletion';
      }
  </script>


  echo '<input type="button" onclick="ConfirmDelete()" value="DELETE ACCOUNT">';
like image 21
Richard Avatar answered Sep 22 '22 22:09

Richard