选择第一个值以外的值时,如何自动提交下拉列表? [英] How do I auto submit a dropdown when a value is selected other than the first value?
本文介绍了选择第一个值以外的值时,如何自动提交下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前代码:
<select name='PreviousReceiver' onchange='this.form.submit()'>
<option value='0'>Contact List</option>
<option value='1'>blah</option>
<option value='2'>blah2</option>
<option value='3'>blah3</option>
</select>
所以我有这个下拉框,当用户点击它时会自动提交.它的工作方式很好,但如果用户选择了第一个值(见上文),我不希望它提交.
So I have this dropdown box that auto submits when the user clicks it. It works fine the way it is, but I dont want it to submit if the user has the first value selected(see above).
换句话说,如果用户点击联系人列表,那么我不希望它提交表单.
In other words, if the user clicks contact list, then I don't want it to submit the form.
我试过这个:
onchange="if(this.value != '0') this.form.submit()"
但这只是让它永远不会激活.
but that just made it never activate.
有什么建议吗?
推荐答案
尝试不使用引号并检查.
Try without quotes and check.
<form method="post">
<select name='PreviousReceiver' onchange='if(this.value != 0) { this.form.submit(); }'>
<option value='0'>Contact List</option>
<option value='1'>blah</option>
<option value='2'>blah2</option>
<option value='3'>blah3</option>
</select>
</form>
这篇关于选择第一个值以外的值时,如何自动提交下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文