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. Link to comment https://forums.phpfreaks.com/topic/119148-solved-javascriptphp-problemquery/ 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> Link to comment https://forums.phpfreaks.com/topic/119148-solved-javascriptphp-problemquery/#findComment-613552 Share on other sites More sharing options...
s1yman Posted August 11, 2008 Author Share Posted August 11, 2008 Good thinking ... thanks for the help! Link to comment https://forums.phpfreaks.com/topic/119148-solved-javascriptphp-problemquery/#findComment-613629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.