aztec Posted February 10, 2008 Share Posted February 10, 2008 Hello Part of my database management modules includes an option to delete an entire row from the database, this works without any problems. However I would like to include an option that after the DELETE is clicked a YES or No button would be displayed before the actual delete in the MYSQL database took place, to allow second thoughts. i.e. click YES to delete or click NO to cancel the delete operation. I have been searching both the forum and the Web with no success. Any help or guidances much appreciated. Kind Regards Quote Link to comment https://forums.phpfreaks.com/topic/90394-delete-yn-option/ Share on other sites More sharing options...
Northern Flame Posted February 10, 2008 Share Posted February 10, 2008 you can do this with javascript: something like <script type="text/javascript"> function confirmDelete(){ var answer = confirm("Delete Row?"); if(answer){ alert("Row Deleted!"); window.location = "http://www.yourwebsite.com/delete-row.php"; } else{ alert("Row was not deleted!"); } } </script> <a href="javascript:void(0)" onClick="confirmDelete()">Delete</a> Quote Link to comment https://forums.phpfreaks.com/topic/90394-delete-yn-option/#findComment-463424 Share on other sites More sharing options...
tippy_102 Posted February 10, 2008 Share Posted February 10, 2008 This is easy: <a href="delete.php" onClick="return confirm('Delete item?');">Delete</a> Quote Link to comment https://forums.phpfreaks.com/topic/90394-delete-yn-option/#findComment-463425 Share on other sites More sharing options...
aztec Posted February 10, 2008 Author Share Posted February 10, 2008 Hello Many thanks for your response. Obviously I will try all options but at this time there is no javascript used in the modules therefore I would prefer to use PHP if at all possible. <a href="delete.php" onClick="return confirm('Delete item?');">Delete</a> Is onClick a javascript function. Regards Quote Link to comment https://forums.phpfreaks.com/topic/90394-delete-yn-option/#findComment-463431 Share on other sites More sharing options...
marcus Posted February 10, 2008 Share Posted February 10, 2008 Yes, it is. for php you can do something like <form method="post" action="deleterow.php"> <input type="hidden" name="row" value="<?php echo $row['id']; ?>"> <input type="submit" name="submit" value="Yes"><input type="submit" name="submit" value="No"> </form> //deleterow.php <?php $submit = $_POST['submit']; if($submit == 'Yes'){ // delete row }else { // do something else } ?> Quote Link to comment https://forums.phpfreaks.com/topic/90394-delete-yn-option/#findComment-463435 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.