john666 Posted November 11, 2013 Share Posted November 11, 2013 i have Links like View | Update | Delete | Opreation for student Record on Student ID base On Delete link there is a Page name Std_delete.php and here is its Code ----------------------------- <?php $id=$_REQUEST['student_id']; if($id) { include('config.php'); if ($id) { mysql_query("delete from student where std_id=$id"); header("Location:classes.php"); } } ?> But i want that when Some 1 try to delete Record its first ask from USer ..Do you Want to delete Reocrd should run a javascript Code How and where i have to add that Code ??? Link to comment https://forums.phpfreaks.com/topic/283807-delete-confirmation-in-php/ Share on other sites More sharing options...
kicken Posted November 11, 2013 Share Posted November 11, 2013 A quick and dirty method is to just use onclick and confirm(): <a href="std_delete.php?student_id=12345" onclick="return confirm('Do you really want to delete this student?');">Delete</a> A better but more involved method would be to use a modal dialog such as jQuery UI's dialog to prompt the user, then send a POST via ajax to delete the item if confirmed. <a href="std_delete.php?student_id=12345" class="delete-link">Delete</a> <script type="text/javascript"> $('.delete-link').click(function(e){ $('<div>').text('Do you really want to delete this student?').dialog({ modal: true , buttons: { "Yes": function(){ $.post(e.target.href); } } } }); </script> The above is just a rough outline of the code, not a functional example. Check the documentation for jQuery and jQuery UI and you can finish it up. Link to comment https://forums.phpfreaks.com/topic/283807-delete-confirmation-in-php/#findComment-1457908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.