在 http://ip.qq.com/ 的网站中有QQ自己的JS省市区三级联动
QQ是使用引用外部JS来实现三级联动的。JS如下:http://ip.qq.com/js/geo.js
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>QQ JS省市区三级联动</title> 5 <!-- 直接使用QQ的省市区数据 --> 6 <!-- 7 <script type="text/javascript" src="http://ip.qq.com/js/geo.js"></script> 8 --> 9 <script type="text/javascript" src="geo.js"></script> 10 </head> 11 <body onload="setup();preselect('陕西省');promptinfo();"> 12 <form> 13 <select class="select" name="province" id="s1"> 14 <option></option> 15 </select> 16 <select class="select" name="city" id="s2"> 17 <option></option> 18 </select> 19 <select class="select" name="town" id="s3"> 20 <option></option> 21 </select> 22 <input id="address" name="address" type="hidden" value="" /> 23 <input onclick="alert(document.getElementById('address').value); return false;" type="submit" value="提交" /> 24 </form> 25 <script> 26 27 //这个函数是必须的,因为在geo.js里每次更改地址时会调用此函数 28 function promptinfo() 29 { 30 var address = document.getElementById('address'); 31 var s1 = document.getElementById('s1'); 32 var s2 = document.getElementById('s2'); 33 var s3 = document.getElementById('s3'); 34 address.value = s1.value + s2.value + s3.value; 35 } 36 37 </script> 38 </body> 39 </html>