我的弹出窗口没有出现原因?

时间:2013-06-07 08:28:11

标签: php html alert

echo '<a href="editContact.php?edit=1&id= '.$pid .'&cid= '.$cid.'"><img src="images/edit.png" width="30" height="30" /></a>    <a href="delete.php?cid='.$row["ContactID"].'&id='. $pid . '&createdby='. $row["CreatedBy"] . '" onclick=\"return confirm("Are you sure you want to remove this contact?");\" >

我的警告框在HTML中运行良好,但是当我尝试在PHP中回显它时,它不起作用,但我仍然可以删除,有人可以帮助我吗?

4 个答案:

答案 0 :(得分:2)

这很有效。

echo '<a href="editContact.php?edit=1&id= '.$pid .'&cid= '.$cid.'"><img src="images/edit.png" width="30" height="30" /></a> 
    <a href="delete.php?cid='.$row["ContactID"].'&id='. $pid . '&createdby='. $row["CreatedBy"] . 
        '" onclick="return confirm(\"Are you sure you want to remove this contact?\");" >';

答案 1 :(得分:1)

你似乎逃过了错误的报价。

onclick=\"return confirm("Are you sure you want to remove this contact?");\"

试试这个:

onclick="return confirm(\'Are you sure you want to remove this contact?\');"

...因为你用单引号包装回声,而不是双引号。

答案 2 :(得分:1)

您需要escape the quotes

在PHP中使用 double - 引用字符串they are interpreted instead of being string literals时,您可能还会发现变量名称很方便。

答案 3 :(得分:0)

您无法使用onclick=\"return confirm('Are you sure you want to remove this contact?');\"

来“使用”
相关问题