[英]How to create a function Javascript pop up box with php code?
In a php page, I want to make a remove button to delete data in my database. 在php页面中,我要创建一个删除按钮以删除数据库中的数据。 This button would be able to show a pop up box to ask 'yes' or 'no' before you confirm to delete. 在确认删除之前,此按钮将能够显示一个弹出框,询问“是”或“否”。
"<input type=submit value=Remove onclick='confirm(\"Are you sure to remove Title " . $row['AlbumName'] . " ?\");'>"
This code just can call the pop up box but it can't check the user either click 'yes' or 'no'. 该代码只能调用弹出框,但是无法单击“是”或“否”来检查用户。
I have tried to echo script with confirm function remove() in , but the function is not work when I set onclick=remove() . 我尝试用中的确认函数remove()回显脚本,但是当我设置onclick = remove()时,该功能不起作用。
Try this 尝试这个
<input type=submit value=Remove onclick='confirmDelete(<?=$row['AlbumName']?>);'>
function confirmDelete(AlbumName)
{
var agree=confirm("Are you sure to remove Title "+AlbumName+"?");
if (agree)
return true ;
else
return false ;
}
function doublecheckDelete() {
if (confirm("really delete") == true) {
document.deleteform.submit();
} else {
alert ("ok, not deleting.");
}
}
<form name="deleteform" action="delete.php">
... whatever else you need ...
<input type=button onClick="doublecheckDelete()">
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.