我正在使用jQuery UI Dialog来创建一个弹出窗口,询问“你确定要删除”我从开始链接到该函数,检查是否允许删除它然后弹出是没问题。然后,如果他们说YES将脚本发送到删除脚本,或者如果他们说不,则将它们发送回起始页面。
我现在的脚本没有自动打开对话框,我以为我理解了自动打开的方向,但它没有用。另外我需要它有两个链接,一个用于YES,一个用于NO。
这是删除数据的起始链接
$result = $db->query("SELECT * FROM customers WHERE pid = '$pid'");
foreach($result as $key => $value) {
echo '<tr>';
echo '<td>';
echo $value['name'];
echo '</td>';
echo '<td>';
echo $value['contact'];
echo '</td>';
echo '<td>';
echo "<a href = prosscust.php?custid=" . $value['custid'] . "&pid=" . $pid . "&name=" . $value['name'] . "></a>";
echo '</td>';
echo '</tr>';
}
prosscust.php
require("function.php");
$pid = $_SESSION['profile']['id'];
checkcustomeruse($custid,$pid,$name);
这是它所调用的功能
$custid = $_GET['custid'];
$pid = $_GET['pid'];
$name = $_GET['name'];
function checkcustomeruse($custid,$pid,$name){
global $db;
$sql = "SELECT COUNT(*) from signings WHERE pid = ? AND custid = ?";
$stmt = $db->prepare($sql);
$stmt->bindParam(1, $pid, PDO::PARAM_INT);
$stmt->bindParam(2, $custid, PDO::PARAM_STR);
$stmt->execute();
$number_of_rows = $stmt->fetchColumn();
$number = $number_of_rows;
//echo $number;
//exit;
if($number == 0)
{
?>
<div id="callConfirm" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
<?php
}
else
{
$Message = 'You can not delete this customer because it has signings attached to it.';
header("Location: viewallcustomer.php?Message=" . urlencode($Message));
}
}
这是jquery脚本
$(function() {
$( "#dialog-confirm" ).dialog({
autoOpen: true,
resizable: false,
height:140,
modal: true,
buttons: {
"Delete all items": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
答案 0 :(得分:0)
是&#34; callConfirm&#34;您试图成为对话的div?如果是这样,将您的javascript更改为此,它应该工作。你正在使用的选择器不存在。
$(function() {
$( "#callConfirm" ).dialog({
autoOpen: true,
resizable: false,
height:140,
modal: true,
buttons: {
"Delete all items": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});