0

onsubmit="return confirm('Do you really want to submit the form?')"ユーザーが送信ボタンをクリックしてアイテムを削除する前に、警告を表示するために使用しようとしています。確認ボックスが表示されず、アイテムの削除に直接進みます。

私のコードのどこが間違っているのか、誰にもわかりますか? 二重引用符と一重引用符を変更しようとしましたが、確認ボックスが表示されません。

私のコードは次のとおりです。

    echo '<td> <form method="post" action="deleteassign.php" name="deleteassignform"
 id="deleteassignform" onsubmit="return confirm('Do you really want to submit the form?')">';
    echo '<input type="hidden" name="quizidvalue" id="quizidvalue" value="'.$sendquizid.'" />';
    echo '<input type="hidden" name="classidvalue" id="classidvalue" value="'.$sendclassid.'" />';
    echo '<input type="submit" name="deleteassignment" id="deleteassignment" value="Delete This Assignment"> </form> </td> </tr>';
4

5 に答える 5

2

変更する:

return confirm('Do you really want to submit the form?')

return confirm(\'Do you really want to submit the form?\')

それは間違いなく間違ってqoutedされているので、これがあなたに与えるqoutingの問題を整理するはずです。

于 2013-02-18T17:03:46.697 に答える
1

出力するために...

onsubmit="return confirm('Do you really want to submit the form?')"

...PHP側で引用符を適切にエスケープする必要があります。次のことを試してください(一重引用符の前の円記号に注意してください)。

echo '<td> <form method="post" action="deleteassign.php" name="deleteassignform"
 id="deleteassignform" onsubmit="return confirm(\'Do you really want to submit the form?\')">';
于 2013-02-18T17:04:37.560 に答える
0

ボタンに直接コードを入れてみませんか?

<input type="submit" name="deleteassignment" id="deleteassignment" 
value="Delete This Assignment" onclick="return confirm('Do you really want to delete?')">
于 2013-02-18T16:50:24.067 に答える
0

あなたの引用は間違っています。このフォームを使用すると、すべての引用符が正しくなります。

?><td> <form method="post" action="deleteassign.php" name="deleteassignform"
id="deleteassignform" onsubmit="return confirm('Do you really want to submit the form?')">
<input type="hidden" name="quizidvalue" id="quizidvalue" value="<?= htmlspecialchars($sendquizid) ?>" />
<input type="hidden" name="classidvalue" id="classidvalue" value="<?= htmlspecialchars($sendclassid) ?>" />
<input type="submit" name="deleteassignment" id="deleteassignment" value="Delete This Assignment"> </form> </td> </tr>
<?php
于 2013-02-18T17:00:34.123 に答える
0

コードによって出力されるコードは次のようになります。

<form method="post" action="deleteassign.php" name="deleteassignform"
 id="deleteassignform" onSubmit="return confirm('Do you really want to submit the form?');">

関数内の引用に注意してくださいconfirm

于 2013-02-18T17:10:36.053 に答える