这是一个通用的表单代码
<form name="search_form" action="" method="POST">
<input type="text" name="search_text">
<input type="submit" name="search_bt" value="Go">
</form>
有没有办法让确认对话框显示“是”\“否”或“确认”\“取消”等……
我认为dong的一种方式是使用CSS Layer、JavaScript和Php...在按钮上有一个php isset(){}
检查,当设置时显示一个显示两个按钮和onclick=func()
JS功能的按钮显示的Div有一个php变量(标志)设置,然后我可以if(flag){}
继续或跳过一些代码...
嗯,这是可行的,另外一点是我可以有一个主题很好的对话框,但我只是想让我的生活更容易……
发布于 2010-09-03 10:02:52
您也可以使用表单标记本身中的一行来完成此操作
<form action="exampleHandlerPage.php" method="post" onsubmit="return confirm('Are you sure you want to submit?');">
发布于 2016-07-17 00:11:38
如果在一个表单中有两个或多个提交按钮:
<input type="submit" value="Edit">
<input type="submit" name="delete" value="Delete" onclick="return confirm('Confirm, please.');">
仅当您单击Delete
按钮时,才会显示该对话框。
发布于 2010-09-03 09:50:02
使用不带任何div的原始javascript
...
你可以拥有这个function
function confirmSubmit() {
if (confirm("Are you sure you want to submit the form?")) {
document.getElementById("FORM_ID").submit();
}
return false;
}
可以从表单中的onsubmit
事件调用该函数,也可以在button
中的onclick
事件上调用该函数。
顺便问一下,你听说过JQuery
吗。它是一个JS库,里面有很多有用的东西,可以让你以一种舒适而优美的方式编写javascript。
作为您想要完成的操作的示例,请以JQuery
中的这个confirmation dialog为例
https://stackoverflow.com/questions/3632530
复制相似问题