日期:2014-05-16 浏览次数:20585 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="../Scripts/jquery-1.3.2.min-vsdoc.js" type="text/javascript"></script> <script language="javascript"> $( function() { //读取所有省份 $.getJSON("/JSTest/GetProvince", function(json) { document.getElementById("selprovince").length = 0; //添加显示省份 $(json).each( function() { var op = new Option(); op.value = this.Id; op.text = this.Name; document.getElementById("selprovince").options.add(op); } ); }); } ); //获取指定省份到城市 function GetCity(pid) { $.getJSON("/JSTest/GetCity", { PId: pid }, function(json) { document.getElementById("selcity").length = 0; $(json).each( function() { var op = new Option(); op.value = this.CId; op.text = this.CName; document.getElementById("selcity").options.add(op); } ); }); } </script> </head> <body> <select id="selprovince" onchange="GetCity(this.value);"> <option value="s">--请选择--</option> </select> <select id="selcity"> </select> </body> </html>
------解决方案--------------------
我的资源中有,而且比较全面,中国的所有省县市都显示,而且还有一个demo你可以学习一下,不用调试可以直接用