当html select表单更改时,弹出警报,然后发送表单 [英] When html select form changes, pop up alert then send form
本文介绍了当html select表单更改时,弹出警报,然后发送表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在表单中的选择上使用onchange ="this.form.submit()",它可以按预期工作,但是当您更改选择下拉菜单并让如果单击确定,则提交表单.如果某人有办法做到这一点,请与您分享. -谢谢
I'm using onchange="this.form.submit()" on a select in a form, it works as expected, but I would like an alert to pop up when you change the select drop down and then have the form submit if you click OK. If someone has a way to do that it would be appreciated if you could share it. -thanks
<form action="/index.php/dashboard/pages/page_statistics/change_collection_type/" method="post">
<input type="hidden" value="690" name="cID">
<select onchange="this.form.submit()" name="ctID">
<option value="4">Blog Entry</option>
<option value="85" selected="selected">Blog Posting</option>
<option value="5">Full</option>
</select>
</form>
推荐答案
使用确认功能.就像警报一样工作,但是如果用户按确定",则返回true,如果按取消",则返回false.
Use the confirm function. Works just like an alert, but returns true if user presses okay, false if they press cancel.
test = confirm("Continue?");
if (test) {
this.form.submit()
}
因此,对于您来说,您可以将其作为on
so for you, you'd put it on your onchange as
onchange="if(confirm('Continue?')){this.form.submit()}"
这篇关于当html select表单更改时,弹出警报,然后发送表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文