您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2024/2/27 14:28:54发布19次查看
html>
head>
meta http-equiv=content-type c />
script type=text/javascript>
var xmlhttp;
var requesttype=;
function createxmlhttprequest()
{
if(window.activexobject)
{
  xmlhttp=new activexobject(microsoft.xmlhttp);
}
else if(window.xmlhttprequest)
{
  xmlhttp=new xmlhttprequest();
}
}
function querycity(citycode){
createxmlhttprequest();
type=city;
var url=data.php?provincecode=+citycode;
xmlhttp.open(get,url,true);
xmlhttp.onreadystatechange=handlestatechange;
xmlhttp.send(null);
}
function queryarea(citycode){
createxmlhttprequest();
type=area;
var url=data.php?citycode=+citycode;
xmlhttp.open(get,url,true);
xmlhttp.onreadystatechange=handlestatechange;
xmlhttp.send(null);
}
function handlestatechange(){
if(xmlhttp.readystate==4){
  if(xmlhttp.status==200){
   if(type==city){
    showcity();
   }else if(type=area){
    showarea();
   }
  }
}
}
function showcity(){
document.getelementbyid(city).innerhtml=xmlhttp.responsetext;
document.getelementbyid(area).innerhtml=;
}
function showarea(){
document.getelementbyid(area).innerhtml=xmlhttp.responsetext;
}
$conn=mysql_connect(localhost,root,2328725);
mysql_select_db(novel);
mysql_query(set names 'utf8');
$sql=select * from province;
$result=mysql_query($sql);
echo \n;
echo \n;
echo 请选择省份\n;
while($row=mysql_fetch_row($result)){
  echo $row[2]\n;
}
echo \n;
echo \n;
echo \n;
echo \n;
?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product