s1yman Posted August 11, 2008 Share Posted August 11, 2008 Hi, I have a php page which when loaded will delete the reletive entry on the MYSQL DB table. I wrote this js script as a last confirmation step before removing the file. <script language="JavaScript" type="text/javascript"> { doyou = confirm("Are you sure you want to delete this offer?"); //The question. if (doyou == false) history.go(-1); //If answered no, it sends you back 1 page) } </script> However, even if the user selects 'no' and gets sent back the php script has already loaded and therefore deleted the entry. Any ideas on how I can make this work the way intended? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
friedemann_bach Posted August 11, 2008 Share Posted August 11, 2008 Simple answer. The javascript confirmation should be called BEFORE the delete script is loaded. That means, it must be called on the page that appears BEFORE the delete script. Try something like <button onclick="if (confirm('Are you really really sure?')) window.location.href='delete_all.html'">delete everything</button> Quote Link to comment Share on other sites More sharing options...
s1yman Posted August 11, 2008 Author Share Posted August 11, 2008 Good thinking ... thanks for the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.