js实现自动给省市县地区自动赋值

2021-01-23 12:13

阅读:631

标签:city   function   HERE   val   sheng   address   option   from   mes   

1.html部分:

:

}
?>

:

}
?>

县(区):

}
?>

乡(镇、街道):

}
?>

2.js部分:

$(document).ready(function(){
$("#address_sheng").val("{$resmes[‘address_sheng‘]}");

$("#address_sheng_h").val("{$resmes[‘address_sheng‘]}");
$("#address_shi_h").val("{$resmes[‘address_shi‘]}");
$("#address_xian_h").val("{$resmes[‘address_xian‘]}");
$("#address_jie_h").val("{$resmes[‘address_jie‘]}");

change(‘address‘,‘_sheng‘,‘_shi‘,"");

$("#address_cun").val("{$resmes[‘address_cun‘]}");
$("#address_men").val("{$resmes[‘address_men‘]}");

$("#address_xx").val("{$resmes[‘address_xx‘]}");

 

});

3.php 后端代码部分:

$type = $_POST[‘type‘];
if($_POST[‘type‘] ==‘_sheng‘){
$where = " provincecode = ‘".$_POST["pro_code"]."‘";
$resultshi = $Dict->City(‘‘,$where);

$shi = "";
foreach($resultshi as $key=>$val){
$shi .= "";
}
echo json_encode($shi);die;
}
if($_POST[‘type‘] ==‘_shi‘){
// $sqlxian = "select * from area where citycode=‘".$_POST["shi_code"]."‘";
// $resultxian = M()->query($sqlxian);

$where = " citycode=‘".$_POST["pro_code"]."‘";
$resultxian = $Dict->Area(‘‘,$where);

$xian = "";
foreach($resultxian as $key=>$val){
$xian .= "";
}
echo json_encode($xian);die;
}
if($_POST[‘type‘] ==‘_xian‘){
$where = " where areacode=‘".$_POST["pro_code"]."‘";
$sql = "select * from road ".$where;
$resultjie =M()->query($sql);

$jie = "";
foreach($resultjie as $key=>$val){
$jie .= "";
}
echo json_encode($jie);die;
}

js实现自动给省市县地区自动赋值

标签:city   function   HERE   val   sheng   address   option   from   mes   

原文地址:https://www.cnblogs.com/hupengyin/p/13279147.html


评论


亲,登录后才可以留言!