本文实例讲述了javascript实现多级联动下拉菜单的方法。分享给大家供大家参考。具体实现方法如下: 复制代码 代码如下: <br /> <!-- Begin<br /> var arrItems1 = new Array();<br /> var arrItemsGrp1 = new Array();<br /> arrItems1[3] = "列二";<br /> arrItemsGrp1[3] = 1;<br /> arrItems1[4] = "列二三";<br /> arrItemsGrp1[4] = 1;<br /> arrItems1[5] = "列二四";<br /> arrItemsGrp1[5] = 1;<br /> arrItems1[6] = "列三";<br /> arrItemsGrp1[6] = 2;<br /> arrItems1[7] = "列三一";<br /> arrItemsGrp1[7] = 2;<br /> arrItems1[0] = "列四";<br /> arrItemsGrp1[0] = 3;<br /> arrItems1[1] = "列四一";<br /> arrItemsGrp1[1] = 3;<br /> arrItems1[2] = "列四二";<br /> arrItemsGrp1[2] = 3;<br /> var arrItems2 = new Array();<br /> var arrItemsGrp2 = new Array();<br /> arrItems2[21] = "列4-0";<br /> arrItemsGrp2[21] = 0<br /> arrItems2[22] = "列4-1";<br /> arrItemsGrp2[22] = 0<br /> arrItems2[31] = "列41-0";<br /> arrItemsGrp2[31] = 1<br /> arrItems2[34] = "列41-1";<br /> arrItemsGrp2[34] = 1<br /> arrItems2[35] = "列42-0";<br /> arrItemsGrp2[35] = 2<br /> arrItems2[99] = "列24-2";<br /> arrItemsGrp2[99] = 5<br /> arrItems2[100] = "列24-1";<br /> arrItemsGrp2[100] = 5<br /> arrItems2[57] = "列24-0";<br /> arrItemsGrp2[57] = 5<br /> arrItems2[101] = "列2-0";<br /> arrItemsGrp2[101] = 3<br /> arrItems2[102] = "列2-1";<br /> arrItemsGrp2[102] = 3<br /> arrItems2[103] = "列23-0";<br /> arrItemsGrp2[103] = 4<br /> arrItems2[104] = "列23-1";<br /> arrItemsGrp2[104] = 4<br /> arrItems2[105] = "列3-0";<br /> arrItemsGrp2[105] = 6<br /> arrItems2[106] = "列3-1";<br /> arrItemsGrp2[106] = 6<br /> arrItems2[200] = "列31-0";<br /> arrItemsGrp2[200] = 7<br /> arrItems2[201] = "列31-1";<br /> arrItemsGrp2[201] = 7<br /> arrItems2[203] = "列31-2";<br /> arrItemsGrp2[203] = 7<br /> function selectChange(control, controlToPopulate, ItemArray, GroupArray)<br /> {<br /> var myEle ;<br /> var x ;<br /> // Empty the second drop down box of any choices<br /> for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;<br /> if (control.name == "firstChoice") {<br /> // Empty the third drop down box of any choices<br /> for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;<br /> }<br /> // ADD Default Choice - in case there are no values<br /> myEle = document.createElement_x("option") ;<br /> myEle.value = 0 ;<br /> myEle.text = "[列表]" ;<br /> controlToPopulate.add(myEle) ;<br /> for ( x = 0 ; x < ItemArray.length ; x++ )<br /> {<br /> if ( GroupArray[x] == control.value )<br /> {<br /> myEle = document.createElement_x("option") ;<br /> myEle.value = x ;<br /> myEle.text = ItemArray[x] ;<br /> controlToPopulate.add(myEle) ;<br /> }<br /> }<br /> }<br /> // End --><br /> 列表一 列表二 列表三 列表四 希望本文所述对大家的javascript程序设计有所帮助。