完成,bug修复
This commit is contained in:
parent
71d37fac5f
commit
381fefa889
@ -34,9 +34,15 @@
|
||||
// console.log(FatherId);
|
||||
getCity(CountryId);
|
||||
CityID=$("#city").val();
|
||||
console.log(CityID);
|
||||
// console.log(CityID);
|
||||
getArea(CityID);
|
||||
|
||||
});
|
||||
$("#city").change(function(){
|
||||
CityID=$("#city").val();
|
||||
// console.log(CityID);
|
||||
getArea(CityID);
|
||||
})
|
||||
|
||||
})
|
||||
</script>
|
||||
|
@ -16,16 +16,7 @@ function getData(){
|
||||
}
|
||||
|
||||
|
||||
function getCountry(){
|
||||
// $.ajax({
|
||||
// url : './json/third-level-address.json',
|
||||
// type : 'get',
|
||||
// async: false,
|
||||
// success : function(data) {
|
||||
// if(data=="error"){
|
||||
// alert("系统错误");
|
||||
// return;
|
||||
// }
|
||||
function getCountry(){
|
||||
var data = getData();
|
||||
var country = new Array();
|
||||
var children = new Array();
|
||||
@ -36,9 +27,8 @@ function getCountry(){
|
||||
children.push(tmp.children);
|
||||
});
|
||||
// for(var i in data){
|
||||
// console.log(data[i].children[0].children[0].code);
|
||||
// console.log(data[i].children[0].children.length);
|
||||
// }
|
||||
// console.log(data[0].children[1].name);
|
||||
var options = "<option value='0'>--请选择--</option>";
|
||||
for(var i in data){
|
||||
options += "<option value='" + data[i].code + "' selected>" + dataJson[i].name+"</option>";
|
||||
@ -52,9 +42,12 @@ function getCity(countryCode){
|
||||
$('#city').empty();
|
||||
var options = "<option value='0'>--请选择--</option>";
|
||||
for(var i in data){
|
||||
if(countryCode && countryCode == data[i].code){
|
||||
options += "<option value='" + data[i].children[0].code + "' selected>" + data[i].children[0].name+"</option>";
|
||||
for(let j=0;j<data[i].children.length;j++){
|
||||
if(countryCode && countryCode == data[i].code){
|
||||
options += "<option value='" + data[i].children[j].code + "' selected>" + data[i].children[j].name+"</option>";
|
||||
}
|
||||
|
||||
}
|
||||
$("#city").html(options);
|
||||
}
|
||||
|
||||
@ -63,9 +56,13 @@ function getArea(cityCode){
|
||||
var data = getData();
|
||||
var options = "<option value='0'>--请选择--</option>";
|
||||
for(var i in data){
|
||||
if(cityCode && cityCode == data[i].children[0].code){
|
||||
options += "<option value='" + data[i].children[0].children[0].code + "' selected>" + data[i].children[0].children[0].name+"</option>";
|
||||
}
|
||||
for(let j=0;j<data[i].children.length;j++){
|
||||
for(let k=0;k<data[i].children[j].children.length;k++){
|
||||
if(cityCode && cityCode == data[i].children[j].code){
|
||||
options += "<option value='" + data[i].children[j].children[k].code + "' selected>" + data[i].children[j].children[k].name+"</option>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#area").html(options);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user