当html select表单更改时,弹出警报,然后发送表单

编程入门 行业动态 更新时间:2024-10-08 22:45:25
本文介绍了当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表单更改时,弹出警报,然后发送表单

本文发布于:2023-11-28 01:05:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640356.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   弹出   警报   html   select

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!