HTML - 表单提交按钮确认对话框
这是一个通用的表单代码
<form name="search_form" action="" method="POST">
<input type="text" name="search_text">
<input type="submit" name="search_bt" value="Go">
</form>
,有没有办法可以有一个确认对话框,显示“是”\“否”或“确认”\“取消”等...
我想到的一种方法是使用 CSS 层、JavaScript 和 Php ...按钮上有一个 php isset(){}
chechk,设置后会显示一个带有两个按钮的 Div 和这些按钮的 onclick=func()
JS 函数按钮设置了一个 php 变量(标志),然后我可以 if(flag){}
继续或跳过一些代码...
好吧,这将起作用,而且优点是我可以有一个主题很好的对话框,但我只是想让我的生活更轻松......
this is a general form code
<form name="search_form" action="" method="POST">
<input type="text" name="search_text">
<input type="submit" name="search_bt" value="Go">
</form>
is there a way could have a confirmation dialog saying 'Yes'\'No' or 'Confirm'\'Cancel' etc...
One way i figured of dong is is with CSS Layer and JavaScript and Php... that have a php isset(){}
chechk on the button and when set display a Div displayed with two buttons and onclick=func()
JS function of those buttons have a php variable(flag) set and then i can if(flag){}
to continue or skip some code...
well that is going to work and plus point is that i can have a well themed dialog box but i just wanna make my life easier...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您也可以使用表单标签本身中的一行来完成此操作
You can also do it with one line in the form tag itself
如果一张表单中有 2 个或更多提交按钮:
仅当您单击
Delete
按钮时才会显示该对话框。If you have 2 or more submit buttons in one form:
The dialog shows up only when you click the
Delete
button.使用原始
javascript
而不带任何div...您可以拥有此
函数
并且您可以从表单中的
onsubmit
事件调用该函数,或者在按钮
中的onclick
事件上。顺便说一句,您听说过
JQuery
。它是一个 JS 库,包含许多有用的东西,为您提供一种舒适而美观的 javascript 编码方式。作为您想要完成的操作的示例,请使用以下确认对话框: a href="http://jquery.com/" rel="nofollow noreferrer">
JQuery
为例Using raw
javascript
without any div...You can have this
function
And you can call that function from the
onsubmit
event in the form, or on theonclick
event in thebutton
.By the way, have you heard about
JQuery
. Its a JS Library with a lot of helpful things that give you a comfort and beauty way of coding javascript.As an example of what you want to get done, take this confirmation dialog from
JQuery
as example这个 javascript 是否可以存储与标签“form”不同的内容,替换
为类似的内容
is this javascript can be store diferent from tag "form", replace
with something like