我在这里尝试了许多示例,但我可以让我的代码在删除之前实际显示一个弹出窗口。我使用的代码可以在这里找到:
echo "<td><button class='btn'><a href=\"deleteuserExecute2.php?login=" .$login. "\" onClick=\"return confirm(\'Delete this Account?\')\"; >DELETE ACCOUNT </a></button></td>";
我在这里尝试了许多示例,但我可以让我的代码在删除之前实际显示一个弹出窗口。我使用的代码可以在这里找到:
echo "<td><button class='btn'><a href=\"deleteuserExecute2.php?login=" .$login. "\" onClick=\"return confirm(\'Delete this Account?\')\"; >DELETE ACCOUNT </a></button></td>";
您只需要使用onclick
链接或按钮的方法:
<a href="DELETE_PAGE" onClick="return confirm('Delete This account?')">Delete Account</a>
<script type="text/javascript">
function ConfirmDelete()
{
if (confirm("Delete Account?"))
location.href='linktoaccountdeletion';
}
</script>
echo '<input type="button" onclick="ConfirmDelete()" value="DELETE ACCOUNT">';
试试这个
<form action="url/to/delation_page" onSubmit="return confirm('are you sure?')">
</form>
说啊
onclick="return confirm('Are you sure you want to delete?')"
^^^^^^ --> this is very important step...
javascript确认
function doConfirm(id)
{
var ok = confirm("Are you sure to Delete?")
if (ok)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
window.location = "create_dealer.php"; // self page
}
}
xmlhttp.open("GET", "delete_dealer.php?id=" + id);
xmlhttp.send();
}
}
删除按钮
<input type="button" onclick="doConfirm();"/>
如果你使用点击数据将被删除,但要查看结果你必须手动刷新页面而不是使用 onSubmit="return confirm('are you sure?')"
觉得有帮助!