PHP Onclick Popup
I would like a "popup" to appear when a user clicks the delete button in a CMS. I have the following code:
<?php echo ("<a href='d开发者_Go百科elete_donor.php?id=$row->id' class='delete_icon2' title='Delete Donor' onclick='return confirm('Are you sure you want to delete this entry?')'></a></td>");?>
I've used the "onclick" option successfully before, but not in a PHP environment. The above code seems to ignore the "onclick" statement. I'm thinking I may have an issue with the quotation marks and have tried several other options but to no avail.
Thanks for your help!!
Don't echo HTML. Just let PHP output it directly.
<a href="delete_donor.php?id=<?php echo $row->id; ?>" class="delete_icon2" title="Delete Donor"
onclick="return confirm('Are you sure you want to delete this entry?')"></a></td>
Anything not inside <?php ?>
tags is echoed directly to stdout.
It isn't a PHP issue.
onclick='return confirm('Are you sure you want to delete this entry?')'
is not going to work since you use '
for two different things.
Change it to
onclick='return confirm(\"Are you sure you want to delete this entry?\")'
and it should work.
精彩评论