我想在php中创建一个确认是/否的框,我的代码如下:
<?php
if(isset($_REQUEST['id']))
{
?>
<script>
var cf=confirm("do you want to delete Y/N");
if(cf)
{ i want to call code edit of php
}
</script>
<?php
}
?>
<html>
<head>
</head>
<body>
<form name="frm" method="post" action="edit.php">
<a href="edit.php?id=1">Edit </a> <br>
<a href="edit.php?id=2">Edit </a> <br>
<a href="edit.php?id=3">Edit </a> <br>
</form>
</body>
</html>我想当按下是时,我在PHP中调用代码编辑,但它不起作用。你能帮我吗?谢谢你
发布于 2016-04-28 15:17:49
在您的表单上添加id:
为窗体的onsubmit事件创建事件侦听器
<script>
function onFormSubmission(e){
return confirm("do you want to delete Y/N");
}
var frm = document.getElementById('frm');
frm.addEventListener("submit", onFormSubmission);
</script>当用户提交表单时,他们将收到您的消息提示。如果他们单击Yes,函数将返回true,表单将被提交。否则,函数将返回false,表单提交将被取消
https://stackoverflow.com/questions/36907601
复制相似问题