js实现自动给省市县地区自动赋值
2021-01-23 12:13
标签:city function HERE val sheng address option from mes 1.html部分: 省: } 市: } 县(区): } 乡(镇、街道): } 2.js部分: $(document).ready(function(){ $("#address_sheng_h").val("{$resmes[‘address_sheng‘]}"); change(‘address‘,‘_sheng‘,‘_shi‘,""); $("#address_cun").val("{$resmes[‘address_cun‘]}"); $("#address_xx").val("{$resmes[‘address_xx‘]}"); }); 3.php 后端代码部分: $type = $_POST[‘type‘]; $shi = ""; $where = " citycode=‘".$_POST["pro_code"]."‘"; $xian = ""; $jie = ""; js实现自动给省市县地区自动赋值 标签:city function HERE val sheng address option from mes 原文地址:https://www.cnblogs.com/hupengyin/p/13279147.html
?>
?>
?>
?>
$("#address_sheng").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‘]}");
$("#address_men").val("{$resmes[‘address_men‘]}");
if($_POST[‘type‘] ==‘_sheng‘){
$where = " provincecode = ‘".$_POST["pro_code"]."‘";
$resultshi = $Dict->City(‘‘,$where);
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);
$resultxian = $Dict->Area(‘‘,$where);
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);
foreach($resultjie as $key=>$val){
$jie .= "";
}
echo json_encode($jie);die;
}
下一篇:php接口数据安全解决方案