jaminxz Posted February 23, 2009 Share Posted February 23, 2009 Hi guys, i have some rows, each with a checkbox on a php webpage. When the 'submit' button is clicked, each row with a checked checkbox has its status field updated. This all works fine but now i have tried to put a simple javascript pop-up box in to ask the user if he/she is sure she wants to update the selected recrod(s). My problem is that if whatever the user selects (ok or cancel) the post still happens and the fields are updated. I'd really appreciated it if someone could look over a newbie's code and point me in the right direction!thanks in advance, Jaminxz. <!----------------in the head <script language="javascript1.2"> var form_id; function confirm_delete(go_url) { var answer = confirm("Are you sure to delete the selected row?"); if (answer) { location=go_url; } } </script> <!---------------the form <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" id="Updated_Rows_Form"> <!-----------the button <input type="submit" name="Confirm" value="Close Selected" onClick="confirm_delete('<?php echo $_SERVER['PHP_SELF'];?>')" /> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 23, 2009 Share Posted February 23, 2009 get rid of the onclick in the submit button, and change your form tag to: <form action="" method="post" id="Updated_Rows_Form" onsubmit="return confirm('Are you sure to delete the selected row(s)?');"> ...i also removed the action, since it will default to itself if it's empty Quote Link to comment Share on other sites More sharing options...
jaminxz Posted February 23, 2009 Author Share Posted February 23, 2009 thats great - works a treat! many thanks. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 23, 2009 Share Posted February 23, 2009 np - don't forget to mark it solved 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.