3

我试图在用户删除数据之前将弹出消息放入此代码中。这是我的代码。

while ($test = mysql_fetch_array($result))
{
    $id = $test['FailID'];

    echo "<tr align='center'>"; 
    echo"<td><font color='black'>" .$test['FailID']."</font></td>";
    echo"<td><font color='black'>" .$test['TajukFail']."</font></td>";
    echo"<td><font color='black'>". $test['JilidFail']. "</font></td>";
    echo"<td><font color='black'>". $test['StatusFail']. "</font></td>";    
    echo"<td> <a href ='daftarkemaskini.php?FailID=$id'>Edit</a>";
    echo"<td> <a href ='padamfail.php?FailID=$id'><center>Delete</center></a>";

    echo "</tr>";
}

但是当我把它放在那里时,它根本不起作用。

echo"<td> <a href ='padamfail.php?FailID=$id' onClick="return confirm('are you sure you want to delete??');"><center>Delete</center></";>"

谁可以帮我这个事?

4

7 回答 7

5

您需要转义双引号。您的代码最后还有另一个语法错误。

echo "<td> <a href='padamfail.php?FailID=$id' onClick=\"return 
confirm('are you sure you want to delete??');\"><center>Delete</center></a>";
于 2012-12-31T10:57:40.367 回答
2

您将 javascript onclick 代码放在双引号内,用于终止回声。转义双引号:

echo"<td> <a href ='padamfail.php?FailID=$id' onClick=\"return confirm('are you sure you want to delete??');\"><center>Delete</center></a>"
于 2012-12-31T10:58:44.870 回答
1

你可以试试这个——

echo "<td> <a href ='padamfail.php?FailID=$id' onClick=return confirm('are you sure you want to delete??');><center>Delete</center></;>";
于 2012-12-31T11:00:59.833 回答
0

尝试转义字符串:

echo "<td> <a href ='padamfail.php?FailID=$id' onClick=\"return confirm('are you sure you want to delete??');\"><center>Delete</center></";>"
于 2012-12-31T10:58:23.517 回答
0

请换行

 echo"<td> <a href ='padamfail.php?FailID=$id' onClick="return confirm('are you sure you want to delete??');"><center>Delete</center></";>"

echo "<td> <a href ='padamfail.php?FailID=$id' onClick='return confirm('are you sure you want to delete??');' ><center>Delete</center></a>";
于 2012-12-31T11:03:38.993 回答
0
<div class="third">
<input type="button" value="Remove" class="remve" name="<?php echo $row['choice_id']; ?>" onClick="deleteImage(<?php echo $row['choice_id']; ?>)"style="cursor:pointer;">
</div>


<script type="text/javascript">
function deleteImage(x){
var conf = confirm("Are you sure you want to delete this choice?");
if(conf == true){
window.location = "addnewentry/choiceRemove.php?id="+x;
}
}
</script>
于 2012-12-31T11:04:01.147 回答
0

echo"<td><a href='delete.php?id={$row['id']}' onclick='return confirm_alert(this);' >Delete</a></td>"; **你应该试试这个代码,它肯定会工作**

=

<script>

//alert on delete

function confirm_alert(node) {

    return confirm("You are about to permanently delete a product. Click OK to continue or CANCEL to quit.");

}

</script>

<script>

//alert on delete

function confirm_alert(node) {

    return confirm("You are about to permanently delete a product. Click OK to continue or CANCEL to quit.");

}

</script>

希望这会帮助你

于 2018-03-31T13:00:09.540 回答