js三级联动

Posted huang麦穗儿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js三级联动相关的知识,希望对你有一定的参考价值。

$scope.province = [
{ "proID": 1, "proName": "河北省" },
{ "proID": 2, "proName": "湖南省" },
{ "proID": 3, "proName": "河南省" }];
$scope.city = [
{ "cityID": 1, "cityName": "石家庄", "proID": 1 },
{ "cityID": 2, "cityName": "长沙市", "proID": 2 },
{ "cityID": 3, "cityName": "郑州市", "proID": 3},
{ "cityID": 4, "cityName": "南阳市", "proID": 3 },
{ "cityID": 5, "cityName": "驻马店市", "proID": 3}];
$scope.district = [
{ "Id": 1, "DisName": "东城区", "cityID": 1},
{ "Id": 2, "DisName": "西城区", "cityID": 1 },
{ "Id": 3, "DisName": "崇文区", "cityID": 1 },
{ "Id": 4, "DisName": "宣武区", "cityID": 1 },
{ "Id": 5, "DisName": "和平区", "cityID": 2 },
{ "Id": 6, "DisName": "河西区", "cityID": 2 },
{ "Id": 7, "DisName": "河东区", "cityID": 2 },
{ "Id": 8, "DisName": "红桥区", "cityID": 2 },
{ "Id": 9, "DisName": "惠济区", "cityID": 3 },
{ "Id": 10, "DisName": "金水区", "cityID": 3 },
{ "Id": 11, "DisName": "二七区", "cityID": 3},
{ "Id": 12, "DisName": " 高新区", "cityID": 3 },
{ "Id": 13, "DisName": "卧龙区", "cityID": 4 },
{ "Id": 14, "DisName": "唐河县", "cityID": 4 },
{ "Id": 15, "DisName": "西峡县", "cityID": 4 }];
$scope.addName = [];
$scope.addName2 = [];
$scope.selPro = function () {
$scope.selCity = [];
for (var i = 0; i < $scope.city.length; i++) {
if ($scope.city[i].proID == $scope.form.province.proID) {
$scope.selCity.push($scope.city[i]);
}
}
}
$scope.selCit = function () {
$scope.selDistrict = [];
for (var i = 0; i < $scope.district.length; i++) {
if ($scope.district[i].cityID == $scope.form.city.cityID) {
$scope.selDistrict.push($scope.district[i]);
}
}
}













































以上是关于js三级联动的主要内容,如果未能解决你的问题,请参考以下文章

PHP 三级联动

三级联动

省市区三级联动

js三级联动

PHP ajax 实现三级联动

省市区三级联动JS部分简单版