js簡單的二級級聯菜單

table和select在js裏面MS都很重要。。另外,我發現程序員作的就是增長、刪除、修改和查詢。。下面是我作的一個簡單的例子,關於省份的,思路是搞一個數組,而後將相應的省份與對應的市聯繫在一塊兒。。程序也許會有漏洞,但在此僅作一個交流。。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>   <head>     <title>小級聯菜單</title>          <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">     <meta http-equiv="description" content="this is my page">     <meta http-equiv="content-type" content="text/html; charset=UTF-8">         <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->   <script type="text/javascript">     var city=[     ["寧波","金華","杭州","溫州","紹興"],     ["長沙","株州","湘潭","邵陽"],     ["合肥","淮南","淮北","安慶","宿州"],     ["成都","自貢","德陽","綿陽","廣安"]     ];     function getCity(){     var sltprovince=document.getElementById("1province");     var sltcity=document.getElementById("1city");       var provinceCity=city[sltprovince.selectedIndex-1];    //   alert(provinceCity);            for(var i=0;i<provinceCity.length;i++){          sltcity[i+1]=new Option(provinceCity[i]);       }   }   </script>   </head>     <body>    <select id="1province" onchange="getCity()"><option value="0">請選擇省份</option><option value="1">浙江</option><option value="2">湖南</option><option value="3">安徽</option><option value="4">四川</option></select>    <select id="1city"><option value="0">請選擇城市</option></select>   </body> </html>  
相關文章
相關標籤/搜索