中文(繁体)
<!-- 將以下程式碼加入<body>區域 --> <!-- 二級連動開始 --> <script language="JavaScript"> <!-- var subcat = new Array(); subcat[0] = new Array('10','1','=1') subcat[1] = new Array('10','2','=2') subcat[2] = new Array( '10','3','=3') subcat[3] = new Array('10','4','=4') subcat[4] = new Array('10','5', '=5') subcat[5] = 新數組('10','6','=6') subcat[6] = 新數組('10','7','=7') subcat[7 ] = new Array('10','8','=8') subcat[8] = new Array('10','9','=9') subcat[9] = new Array('10' ,'10','=10') subcat[10] = new Array('20','11','=11') subcat[11] = new Array('20','12','=12 ') subcat[12] = new Array('20','13','=13') subcat[13] = new Array('20','14','=14') subcat[14] = new Array('20','15','=15') subcat[15] = new Array('20','16','=16') subcat[16] = new Array('20','17 ','=17') subcat[17] = new Array('20','18','=18') subcat[18] = new Array('20','19','=19') subcat [19] = new Array('20','20','=20') function changeselect1(locationid) { document.form1.s2.length = 0; document.form1.s2.options[0] = new Option('==請選擇==',''); for (i=0; i<subcat.length; i++) { if (subcat[i][0] == locationid) {document.form1.s2.options[document.form1.s2.length] = new Option(subcat [i][1], subcat[i][2]);} } } //--> </script> <form name="form1"> 二級連動: <select name="s1" onChange=" changeselect1(this.value)"> <選項>==請選擇==</選項> <選項值=“10”>1-10</選項> <選項值=“20”>11-20</選項> </select> <select name="s2" onChange="alert(this.value)"> <option>==請選擇==</option> </select> </form> <!-- 二級連動結束--> <!-- 三級連動開始--> <script language="JavaScript"> <!-- var subval = new Array(); subval[0] = new Array('10','單數','1','=1') subval[1] = new Array('10','雙數','2','=2' ) subval[2] = new Array('10','單數','3','=3') subval[3] = new Array('10','雙數','4','=4 ') subval[4] = new Array('10','單數','5','=5') subval[5] = new Array('10','雙數','6','= 6') subval[6] = new Array('10','單數','7','=7') subval[7] = new Array('10','雙數','8',' =8') subval[8] = new Array('10','單數','9','=9') subval[9] = new Array('10','雙數','10', '=10') subval[10] = new Array('20','單數','11','=11') subval[11] = new Array('20','雙數','12' ,'=12') subval[12] = new Array('20','單數','13','=13') subval[13] = new Array('20','雙數','14 ','=14') subval[14] = new Array('20','單數','15','=15') subval[15] = new Array('20','雙數',' 16','=16') subval[16] = new Array('20','單數','17','=17') subval[17] = new Array('20','雙數', '18','=18') subval[18] = new Array('20','單數','19','=19') subval[19] = new Array('20','雙數' ,'20','=20') function changeselect2() { document.form2.s2.length = 0; document.form2.s2.options[0] = new Option('==請選擇==',''); document.form2.s2.options[1] = new Option('選擇單數','單數'); document.form2.s2.options[2] = new Option('選擇雙數','雙數'); document.form2.s3.length = 0; document.form2.s3.options[0] = new Option('==請選擇==',''); } 函數changeselect3(sub1,sub2) { document.form2.s3.length = 0; document.form2.s3.options[0] = new Option('==請選擇==',''); for (i=0; i<subval.length; i++) { if ((subval[i][0] == sub1) & (subval[i][1] == sub2)) {document.form2.s3. options[document.form2.s3.length] = new Option(subval[i][2], subval[i][3]);} } } //--> </script> <form name="form2" > 三級連動: <select name="s1" onChange="changeselect2()"> <option>==請選擇==</option> <option value="10">1-10</option> <option value="20">11-20</option> </select> <select name="s2" onChange="changeselect3(document.form2.s1.value,this.value)"> <option>==請選擇==</option> </select> <select name="s3" onChange="alert(this.value)"> <option>==請選擇==</option> </select> </form> < !-- 三級連動結束-->