php+ajax无刷新实现省、地、市三级联动二

?$conn=mysql_connect(localhost,root,2328725);mysql_select_db(novel);mysql_query(setnames’utf8′);if($provincecode!=$provincecode!=650000$provincecode!=710000$provincecode!=810000$provincecode!=820000$provincecode!=110000$provincecode!=120000$provincecode!=310000$provincecode!=500000){$sql=select*fromcitywhereprovincecode=$provincecode;$result=mysql_query($sql);echoselectonchange=’queryArea(this.options[this.selectedIndex].valueState of Qatar’/n;echooptionvalue=’-1’selected请选取城市/option/n;while($row=mysql_fetch_row($result)){echooptionvalue=’$row[1]’$row[2]/option/n;}echo/select/n;}if($citycode!=){$sql=select*fromareawherecitycode=$citycode;$result=mysql_query($sql卡塔尔国;echoselect/n;echooptionvalue=’-1’selected请选拔县/option/n;while($row=mysql_fetch_row($result)){echooptionvalue=’$row[1]’$row[2]/option/n;}echo/select/n;}?

htmlheadmeta;varrequestType=;functioncreateXMLHttpRequest(){if(window.ActiveXObject){xmlHttp=newActiveXObject(Microsoft.XMLHTTP);}elseif(window.XMLHttpRequest){xmlHttp=newXMLHttpRequest();}}functionqueryCity(citycode){createXMLHttpRequest();type=city;varurl=data.php?provincecode=+citycode;xmlHttp.open(GET,url,true);xmlHttp.onreadystatechange=handleStateChange;xmlHttp.send(null);}functionqueryArea(citycode){createXMLHttpRequest();type=area;varurl=data.php?citycode=+citycode;xmlHttp.open(GET,url,true);xmlHttp.onreadystatechange=handleStateChange;xmlHttp.send(null);}functionhandleStateChange(){if(xmlHttp.readystate==4){if(xmlHttp.status==200){if(type==city){showcity();}elseif(type=area){showarea();}}}}functionshowcity(){document.getElementById(city).innerHTML=xmlHttp.responseText;document.getElementById(area).innerHTML=;}functionshowarea(){document.getElementById(area).innerHTML=xmlHttp.responseText;}/script/headbody?$conn=mysql_connect(localhost,root,2328725);mysql_select_db(novel);mysql_query(setnames’utf8′);$sql=select*fromprovince;$result=mysql_query($sql);echofromid=’form1’/n;echoselectid=’province’onchange=’queryCity(this.options[this.selectedIndex].value卡塔尔’/n;echooptionvalue=’-1’selected请选用省份/option/n;while($row=mysql_fetch_row($result)){echooptionvalue=’$row[1]’$row[2]/option/n;}echo/select/n;echospanid=’city’/span/n;echospanid=’area’/span/n;echo/form/n;?/body/html

发表评论

电子邮件地址不会被公开。 必填项已用*标注