PHP - 如何在没有按钮的情况下提交选择菜单 [英] PHP - How to submit a select menu without a button

查看:74
本文介绍了PHP - 如何在没有按钮的情况下提交选择菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果选择更改而不使用按钮提交表单,是否可以自动提交选择菜单。我的页面上有四个,每个按钮都占用太多空间。通过选择菜单,我的意思是:

Is it possible to auto submit a select menu when the selection changes without using a button to submit the form. I have four of these on my page and using a button for each uses up too much space. By Select Menu, I mean:

<select name="something" class="something" title="something something">
  <option selected="selected">Option One</option>
  <option >Option Two</option>
</select>

我还想为on change事件添加一个确认弹出窗口。以下是我用于按钮的内容,但它不适用于选择菜单。

I would also like to add a confirm popup for the on change event. The following is what I use for buttons but it does not work for the select menu.

onclick="return confirm('do you haz teh codz?');"

任何文章教程或示例的链接都将非常感谢!

Any link to articles tutorials or examples would be greatly appreciated!

谢谢

推荐答案

这是更合适的标记'javascript',因为它是你用来做的javascript它。

This is more appropriately tagged 'javascript' since it's javascript that you'll use to do it.

向select添加'onchange'事件。在下面的示例中,'form'应替换为您最喜欢的定位表单节点的方法。

Add an 'onchange' event to the select. In the example below, 'form' should be substituted for your favourite method of targeting the form node.

<select name="something" class="something" title="something something" onchange="form.submit()">
<option selected="selected">Option One</option>
  <option >Option Two</option>
</select>

这篇关于PHP - 如何在没有按钮的情况下提交选择菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆