JavaScript: 复代码 代码如下: <br>var level1 = ["베이징", "광저우", "상하이"]; <br>var level2 = [["ZhaoYang", "TianTan", "GuGong"], ["Tianhe", "Panyu"], ["PuDong", "PuXi"]]; <br>var level3 = [[["TianShan", "HuangShan"], ["TianTan1", "TianTan2"], ["GuGong1", "GuGong2", "GuGong3", "GuGong4"]], [[" TianHe1", "TianHe2"], ["PanYu1", "PanYu2"]], [["PuDong1", "PuDong2"], ["PuXi1", "PuXi2"]]]; <br>var Levels = { <br>fL: null,//사용용存储各级select的DOM引用 <br>sL: null, <br>tL: null, <br>l1: null, <br>l2: null, <br>l3: null, <br>$: function(id){ <br>return (typeof id == "object") ? id : document.getElementById(id); <br>}, <br>init: function(fID, sID, tID, l1, l2, l3){ <br>this.fL = this.$(fID); <br>this.sL = this.$(sID); <br>this.tL = this.$(tID); <br>this.l1 = l1; <br>this.l2 = l2; <br>this.l3 = l3; <br>this.fL.options.add(new Option("Select",-1));//给一级菜单添加一个“select”标志 <br>for (var i = 0; i < l1. length; i ) { <BR>var item = new Option(l1[i], i); <BR>this.fL.options.add(항목); <BR>} <BR>this.doLev2(); //사용 doLev2函数,处理 2级菜单 <BR>this.doLev3(); //사용 doLev3函数, 处理 三级菜单 <BR>}, <BR>removeSTL: function(){ //사용于删除第이, 3级적 菜单项 <BR>this.sL.options.length = 0; <BR>this.tL.options.length = 0; <BR>}, <BR>removeTL: function(){ //사용할 수 있는 정보 <BR>}, <BR>doLev2: function(){ //관리 2级菜单 <BR>var that = this; <BR>this.fL.onchange = function(){ <BR>that.removeSTL(); //두 번째 선택 <BR>if (that.fL.selectedIndex == 0) { <BR>that.removeSTL(); // //다음 선택 <BR>} <BR>else { <BR>that.sL.options.add(new Option("Select", -1)); //이제이级菜单添加一个“select”标志 <BR>//获取第二级所需的数组 <BR>var items = that.l2[that.fL.selectedIndex - 1]; <BR>for (var i = 0; i < items.length; i ) { //添加第two级的newselect项 <BR>var item = new Option(items[i], i); <BR>that.sL.options.add(항목); <BR>} <BR>} <BR>} <BR>}, <BR>doLev3: function(){ //处理三级菜单 <BR>var that = this; <BR>this.sL.onchange = function(){ <BR>that.removeTL(); //세 번째 선택 <BR>if (that.sL.selectedIndex == 0) { <BR>that.removeTL(); //세 번째 선택 <BR>} <BR>else { <BR>that.tL.options.add(new Option("Select", -1)); //给三级菜单添加一个“select”标志 <BR>//获取第三级所需的数组 <BR>var items = that.l3[that.fL.selectedIndex - 1][that.sL.selectedIndex - 1]; <BR>for (var i = 0; i < items.length; i ) { //添加第3级적 새로운 select项 <BR>var item = new Option(items[i], i); <BR>that.tL.options.add(항목); <BR>} <BR>} <BR>} <BR>} <BR>} <BR>onload = function(){ <BR>Levels.init("첫 번째", "두 번째", "세 번째", level1, 레벨2,레벨3); //사용레벨의 초기화 방법 <BR>} <BR> HTML: 复主代码 代码如下: < ;양식> 演示代码: ì 목 ìë 문ì [Ctrl A ì ì²´é 注:å¦éå¼å ¥ì¸ë¶Jséå·æ°æè½æ§è¡]