PHP5000 Posted 10 hours ago Share Posted 10 hours ago (edited) Hello I want to show an alert or confirmation when somebody click on "delete" button. There are many examples on line and I have read at least 10 posts on some exchange website which sadly has never worked for me (those of you who are old users of internet probably remember a stupid website called expertvillage. This expertexchange sites must be related). The code is pretty straight forward and it actually generate a confirm alert but no matter which option the viewer clicks it goes ahead and deletes (send the viewer to a page that deletes). Just as if there was no confirmation alert at all. I do not know JS and frankly never liked it, but I think it not working has more to do than just me not liking the language. Here is a code, any idea or suggestions is highly appreciated: <form action=deletetest.php method=POST> <input type=submit value=\"Delete records\" onclick=\"ConfirmDelete()\"> </form> <script> function ConfirmDelete() { return confirm("Are you sure you want to delete?"); } </script> Edited 10 hours ago by PHP5000 Quote Link to comment https://forums.phpfreaks.com/topic/325727-example-of-a-functional-confirm-delete/ Share on other sites More sharing options...
requinix Posted 8 hours ago Share Posted 8 hours ago The "expert sex change" website still exists? Wow. That's amazing. The way for this (dated) design to work is that onclick has to return true/false. Right now, all it does is execute a function. Yes, that function returns true/false itself, but nothing happens with that value. It's just like writing function onclick() { ConfirmDelete(); } You should try to do Javascript the modern way, which is "modern" for very good reasons, but if you won't then you fix this problem by making the onclick code "return" a value. Quote Link to comment https://forums.phpfreaks.com/topic/325727-example-of-a-functional-confirm-delete/#findComment-1642479 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.