Jump to content

Using onclick when echoing a link


Nisa8

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.