我想运行一个SQL函数的删除,写在PHP抛出onclick按钮。我想问是/否弹出窗口将答案保存在一个变量中,如果variable==ok运行SQL函数,有人能帮助我吗?这是在PHP上编写的SQL查询:
function DeleteProduct($thisCatalog) {
$connB = new ProductDAO();
$connB->Connect();
$pro_query = "DELETE * FROM Ikea WHERE `CatalogNumber` = $thisCatalog";
$db_result = $connB->ExecSQL($pro_query);
$html_result = 'Your Product Has Been Deleted! ';
$connB->Disconnect();
return $html_result;
}这是delete按钮
<p align=center> <img src="pic/trash.png" title="Delete Product" onclick="conf();submit();">delete函数调用放在哪里?
发布于 2012-09-07 03:26:31
我想这就是你想要的:
$(document).ready(function() {
var answer = confirm("Delete?")
if(answer) {
$.ajax({
url: "delete.php",
type: "post",
data: $('#yourForm').serialize(),
error: function(data) {
alert("There was an error while deleting from the database.");
},
success: function(data) {
// do something
});
});
}
else {
// do something
}
});https://stackoverflow.com/questions/12306923
复制相似问题