Nisa8 Posted January 5, 2011 Share Posted January 5, 2011 Hi, I'm new to php and just trying to practice with some codes I have. I have a php code to delete an entry from a database, all works well but I want to try to use the 'onclick' event to prompt for confirmation. However, when I add this I end up with a blank page. Then original code was: echo('<p>' . $commenttext . '<a href="adddelete.php?deletecomment=' . $commentid . '">' . 'Delete this Comment</a></p>'); I changed it to: echo('<p>' . $commenttext . '<a href="adddelete.php?deletecomment=' . $commentid . ' onclick='return confirm('Are you SURE you want to delete this comment?')'">' . 'Delete this Comment</a></p>'); Anyone know what the problem could be, or an alternative way to get a confirmation before deleting? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/223422-using-onclick-when-echoing-a-link/ Share on other sites More sharing options...
rondog Posted January 5, 2011 Share Posted January 5, 2011 <?php echo("<p>" . $commenttext . "<a href=\"adddelete.php?deletecomment=" . $commentid . "\" onclick=\"return confirm('Are you SURE you want to delete this comment?')\">Delete this Comment</a></p>"); ?> Link to comment https://forums.phpfreaks.com/topic/223422-using-onclick-when-echoing-a-link/#findComment-1154969 Share on other sites More sharing options...
Nisa8 Posted January 5, 2011 Author Share Posted January 5, 2011 Thanks alot Rondog, that's working. Link to comment https://forums.phpfreaks.com/topic/223422-using-onclick-when-echoing-a-link/#findComment-1155031 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.