0
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

4 に答える 4

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?\");" >';
于 2013-06-07T08:42:12.880 に答える
1

引用符をエスケープする必要があります。

また、変数名が PHP の二重引用符で囲まれた文字列で使用されると、文字列リテラルではなく解釈されると便利な場合があります。

于 2013-06-07T08:58:58.783 に答える
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?\');"

...エコーを二重引用符ではなく単一引用符で囲んでいるためです。

于 2013-06-07T08:33:56.780 に答える
0

" inside of " を使用することはできませんonclick=\"return confirm('Are you sure you want to remove this contact?');\"

于 2013-06-07T08:38:51.983 に答える