我想要一个确认框弹出当用户点击“删除”删除记录的方式。Javascript确认PHP函数后
喜欢的东西:
<script language="JavaScript" type="text/javascript" >
function confirmDelete() {
if(confirm("Would you like to delete the selected products?")) {
<?php
$allCheckBoxId = $_POST['checkbox'];
array_map ('mysql_real_escape_string', $allCheckBoxId);
$ids = implode(",", $allCheckBoxId);
$sql = "DELETE FROM products WHERE `id` IN ($ids)";
mysql_query($sql);
?>
}
}
</script>
有了一个onclick:
echo "<input type='submit' name='submit' value='Delete' onclick='confirmDelete()' />";
但我知道这是不可能被使用Javascript & PHP这样在一起。有没有另一种方法来做到这一点?也许PHP有自己的确认?请给出任何想法!
谢谢。
谢谢!很有帮助。 – Catia 2011-12-30 19:10:12
不客气。我很高兴它帮助你! – Jules 2011-12-31 12:00:46