从其他下拉列表中选择值时,设置下拉列表的值 [英] set the value of a drop down list when selecting value from other drop down list
本文介绍了从其他下拉列表中选择值时,设置下拉列表的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个下拉列表
I have two drop down lists
<select id="dropdown1">
<option value="1">Item1</option>
<option value="2">Item2</option>
<option value="3">Item3</option>
<option value="4">Item4</option>
<option value="5">Item5</option>
</select>
<select id="dropdown2">
<option value="6">Item1</option>
<option value="7">Item2</option>
<option value="8">Item3</option>
</select>
当我在第一个下拉列表中选择1时,第二个下拉列表应该显示为6. br />
如果我选择2,则7应显示在第二个,8显示为所有其他。我希望在JQUERY中完成此操作。你能帮我吗?
提前谢谢。
When I select 1 in the first drop down second drop down should show 6.
And if I select 2, 7 should show in second and 8 for all the others. I want this to be done in JQUERY. Can you please help me.
Thanks in advance.
推荐答案
这很简单:只需在SELECT上查看更改事件然后更改其他下拉列表的值如下所示。
This is pretty easy : Just Listen on the change event on SELECT and then change the value of other drop down as below.
(document).ready(function (){
(document).ready(function(){
( #dropdown1)。 ( change,function(){
var other =
("#dropdown1").on("change",function(){ var other=
这篇关于从其他下拉列表中选择值时,设置下拉列表的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文