测试页代码

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

相对原创 测验地方: 测量检验页代码:复制代码 代码如下:

php+ajax动态变化下拉菜单

regionss函数代码:QUOTE: 复制代码 代码如下://省市地3级联合浮动下拉菜单函数regionss省.市.地 functionregionss { global$db;$i=1; $text="省/市/自治区n"; $result=$db->query("SELECTprovinceFROM".TABLE_PROVINCE."WHEREcountry='$country'ORDERBYprovinceid"); while($r=$db->fetch_array { $text.="".$r['province'].""; $i++; } $text.=""; $text.=" 市/县/区n"; $text.="县级市/县n"; return$text; }regions.js的代码: 复制代码 代码如下://varab=newArray(卡塔尔国; varxmlHttp; varxmlHttpa; functioncreateXMLHttpRequest(卡塔尔{ if{ xmlHttp=newActiveXObject; } elseif(window.XMLHttpRequest卡塔尔(قطر‎{ xmlHttp=newXMLHttpRequest(卡塔尔; } } functioncreateXMLHttpRequesta(卡塔尔{ if{ xmlHttpa=newActiveXObject; } elseif(window.XMLHttpRequestState of Qatar{ xmlHttpa=newXMLHttpRequest(卡塔尔(قطر‎; } } functionstartRequest(卡塔尔(قطر‎{ createXMLHttpRequest(卡塔尔(قطر‎; createXMLHttpRequesta(卡塔尔; xmlHttp.onreadystatechange=handleStateChange; xmlHttpa.onreadystatechange=handleStateChangearea; document.getElementById.options.length=0; document.getElementById.options.length=0; varurl=document.form1.select1.value; varqurl="/regions.php?province="+url+"&time="+newDate; xmlHttp.open; xmlHttp.send; //setTimeout",2004卡塔尔国; } functionhandleStateChange(卡塔尔{ if(xmlHttp.readyState==4卡塔尔{ if{ varobj=document.getElementById;//将服务器重回的字符串写到页面中ID为select2的区域 obja=document.getElementById;//将服务器再次回到的字符串写到页面中ID为select3的区域 eval; } } } functionhandleStateChangearea(卡塔尔{ eval(xmlHttpa.responseText卡塔尔国; } //varab=newArray(卡塔尔国; functionstartRequesta(State of Qatar{ createXMLHttpRequesta(卡塔尔(قطر‎; xmlHttpa.onreadystatechange=handleStateChangea; document.getElementById.options.length=0; varurl=document.form1.select2.value; varqurl="/regions.php?city="+url+"&time="+newDate; xmlHttpa.open; xmlHttpa.send; //setTimeout",二〇〇一卡塔尔(قطر‎; } functionhandleStateChangea(卡塔尔国{ if(xmlHttpa.readyState==4卡塔尔(قطر‎{ if{ varobja=document.getElementById; eval(xmlHttpa.responseText卡塔尔(قطر‎; //将服务器重临的字符串写到页面中ID为select3的区域 } } }数据岛regions.php页面代码 复制代码 代码如下:

query("SELECTDISTINCTcityFROM".TABLE_CITY."WHEREprovince='$province'ORDERBYcityid"); while($r=$db->fetch_array { $r[city]=iconv('gb2312','UTF-8',$r[city]); echo"obj.options[obj.options.length]=newOption('".$r[city]."','".$r[美高梅4688官方网站,city]."');n"; $i++; } $resultarea=$db->query("SELECTDISTINCTcityFROM".TABLE_CITY."WHEREprovince='$province'ORDERBYcityid"); $r=$db->fetch_array; $city=$r[city]; $resulta=$db->query("SELECTDISTINCTareaFROM".TABLE_CITY."WHEREcity='$city'ORDERBYcityid"); while($ra=$db->fetch_array { $ra[area]=iconv('gb2312','UTF-8',$ra[area]); echo"obja.options[obja.options.length]=newOption('".$ra[area]."','".$ra[area]."');n"; $i++; } } if{ global$db;$i=1; $result=$db->query("SELECTDISTINCTareaFROM".TABLE_CITY."WHEREcity='$city'ORDERBYcityid"); while($r=$db->fetch_array { $r[area]=iconv('gb2312','UTF-8',$r[area]); echo"obja.options[obja.options.length]=newOption('".$r[area]."','".$r[area]."');n"; $i++; } } ?>地址音信数据库: 选拔的是phpcms3.0里自带的数据库,小编未有举行别的改换本程序能够在phpcms3.0里平素利用,若在其余地点使用请本人改善

本文由美高梅4688官方网站发布于最新话题,转载请注明出处:测试页代码

您可能还会对下面的文章感兴趣: