从下拉列表中选择反映到其他下拉菜单 [英] From the dropdown selection reflect the same to other dropdown
本文介绍了从下拉列表中选择反映到其他下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个相同内容的下拉列表,通过选择一个下拉列表,我希望在其他下拉菜单中反映相同。
再次下拉列表中我有复选框选择。
对于文本框,我确实喜欢
text_id_1 = document .getElementById( text_id_1 跨度>);
text_id_2 = document .getElementById( text_id_2 跨度>);
text_id_2.value = text_id_1.value;
如何进行下拉列表。
Plz建议我。
解决方案
使用selectedIndex
< !DOCTYPE html >
< html >
< head >
< script language = JavaScript >
<! -
function selectChange1(){
document .getElementById( dropdown2)。selectedIndex =
document .getElementById( dropdown1)。selectedIndex;
}
function selectChange2(){
document .getElementById( dropdown1)。selectedIndex =
document .getElementById( dropdown2)。selectedIndex;
}
// - >
< / script >
< / head >
< body >
< select name = dropdown1 onChange = selectChange1() >
< ; 选项 value < span class =code-keyword> = volvo > Volvo < / option >
< 选项 值 = saab > Saab < / option >
< 选项 value = opel > 欧宝< / option >
< < span class =code-leadattribute>选项 value = 奥迪 > 奥迪< / option >
< / select >
< 选择 名称 = dropdown2 onChange = selectChange2() >
< 选项 value = volvo > Volvo < / option >
< ; 选项 value < span class =code-keyword> = saab > Saab < / option >
< 选项 value = opel > 欧宝< / option >
< 选项 value = < span class =code-keyword> audi > 奥迪< / option >
< / select >
< / body >
< / html >
Hi,
I have two dropdowns with same content, by selection of one dropdown I want to reflect same in other dropdown.
In dropdown again I have checkbox selection.
For textbox I did like
text_id_1 = document.getElementById("text_id_1");
text_id_2 = document.getElementById("text_id_2");
text_id_2.value = text_id_1.value;
How to do for dropdown list.
Plz suggest me.
解决方案
Use theselectedIndex
<!DOCTYPE html> <html> <head> <script language="JavaScript"> <!-- function selectChange1() { document.getElementById("dropdown2").selectedIndex = document.getElementById("dropdown1").selectedIndex; } function selectChange2() { document.getElementById("dropdown1").selectedIndex = document.getElementById("dropdown2").selectedIndex; } //--> </script> </head> <body> <select name="dropdown1" onChange="selectChange1()"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> </select> <select name="dropdown2" onChange="selectChange2()"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> </select> </body> </html>
这篇关于从下拉列表中选择反映到其他下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文