我有一个锚标记。哪个是删除行。如果我点击锚标记,则需要 id 并运行查询以进行删除。之后出现javascript警告框以成功提交消息(LOCAL主机说:.....)。一切都很好,但我需要自定义消息或模态弹出窗口。
banner.php是(锚标记):
<?php
query1=mysql_query("select * from slider_details where banner_id='1'") or die (mysql_error());
while($row1=mysql_fetch_array($query1))
{
?>
<tr>
<td><a class="btn btn-xs bg-danger" href="banner.php?bannerdelete=<?php echo $row1['id']; ?>" onclick="return confirm('Are you sure to delete GIF banner?');"> Delete</td>
</tr>
<?php } ?>
banner.php(查询删除):
extract($_REQUEST);
if(isset($bannerdelete)==true)
{
$query=mysql_query("delete from slider_details where id='$bannerdelete'") or die(mysql_error());
echo "<script type='text/javascript'>alert('Deleted Successfully'); </script>";
echo "<script type='text/javascript'>window.location='banner.php' </script>";
}
在上面的查询中,出现查询警告框,然后在banner.php上重定向 但我不需要javascript警告框。
答案 0 :(得分:1)
用户jquery UI对话框小部件
链接:Click
示例:
<div id="dialog" title="Confirm">
Are you sure?
</div>
$("#dialog").dialog({
buttons : {
"Confirm" : function() {
// todo
},
"Cancel" : function() {
$(this).dialog("close");
}
}
});
$("#dialog").dialog("open");
答案 1 :(得分:1)
如果您想自定义提醒,我推荐这个。 SweetAlert
并更改您的代码
echo "<script type='text/javascript'>alert('Deleted Successfully'); </script>";
到这一个。
echo "<script type='text/javascript'> swal('Success!', 'File ".$bannerdelete." has been Deleted.', 'success'); </script>";
答案 2 :(得分:0)
刚刚删除此行伙计!
echo“alert('成功删除');”;
答案 3 :(得分:0)
检查此https://jsfiddle.net/ndkv3075/6/
此处data-id="10"
可以替换为<?php echo $row1['id']; ?>
a id="myBtn" class="btn btn-xs bg-danger" href="#" data-id="10"> Delete </a>
btn.onclick = function() {
event.preventDefault();
var id= this.dataset.id;
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
window.location = '<your url>/banner.php?bannerdelete=' + id
} else {
swal("Your imaginary file is safe!");
}
});
}