marukochan Posted March 16, 2007 Share Posted March 16, 2007 Hi! How can I have a dialog box to confirm with the user whether he really wants to delete a specific record. My code: Here is where the user click the 'thrash' icon to delete a record. ..... echo("<td width=15% align=middle><a href='admin_delete.php?id=".$row["project_id"]."'><img src='images/icon_delete.gif' border='0'></a>"); ..... So, before deleting the record I want to have a dialog box to confirm whether he wants to proceed with the deleting or not. How can I do that ? TQ Link to comment https://forums.phpfreaks.com/topic/42958-solved-how-to-include-yesno-dialog-box/ Share on other sites More sharing options...
only one Posted March 16, 2007 Share Posted March 16, 2007 if(!$dialogbox){ echo "please select box"; }else{ whatever you want ;} Link to comment https://forums.phpfreaks.com/topic/42958-solved-how-to-include-yesno-dialog-box/#findComment-208659 Share on other sites More sharing options...
Fergusfer Posted March 16, 2007 Share Posted March 16, 2007 How can I have a dialog box to confirm with the user whether he really wants to delete a specific record. A true dialog box cannot be spawned from pure PHP. It's a client-side action, so you need to use Javascript. You could add an onclick attribute to the anchor tag for the delete link. Something like this: <a onclick="return confirm('Are you sure you want to delete this record?);" href="admin_delete.php?id=[...] Please note that single-quoting attribute values is not XHTML-compliant. Link to comment https://forums.phpfreaks.com/topic/42958-solved-how-to-include-yesno-dialog-box/#findComment-208670 Share on other sites More sharing options...
marukochan Posted March 16, 2007 Author Share Posted March 16, 2007 Ferguser, If I try to write this way within html, it is working .... <td width=15% align=middle><a href="admin_delete.php?id="<? echo $row["project_id"]; ?>"" onClick="javascript:return confirm('Are you sure you want to delete this record?')"><img src='images/icon_delete.gif' border='0'></a>"); ... but when I wrote it this way within php, it is not working. I am so confused. How and when should I use single or double quoting. Can you correct my single and double quoting in this code? .... echo("<td width=15% align=middle><a href='admin_delete.php?id=".$row["project_id"]."' onClick='javascript:return confirm('Are you sure you want to delete this record?')'><img src='images/icon_delete.gif' border='0'>[/a]"); .... Link to comment https://forums.phpfreaks.com/topic/42958-solved-how-to-include-yesno-dialog-box/#findComment-208675 Share on other sites More sharing options...
monk.e.boy Posted March 16, 2007 Share Posted March 16, 2007 .... echo '<td width=15% align=middle>'; echo '<a href="admin_delete.php?id='. $row["project_id"] .'" '; echo 'onClick="javascript:return confirm(\'Are you sure you want to delete this record?\')">'; echo '<img src="images/icon_delete.gif" border="0">'; .... monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42958-solved-how-to-include-yesno-dialog-box/#findComment-208705 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.