This article mainly introduces how JavaScript achieves a simple association between province, city, and county levels. It analyzes the specific steps and related implementation skills of JavaScript to achieve the association between province, city, and county levels in the form of a complete example, if you need it, you can refer to the example in this article to describe how js achieves simple provincial/municipal/county-level linkage. We will share this with you for your reference. The details are as follows:
Js Code
// Province/city/county data format var province_city_county_data = [{province: "Sichuan", city: [{cityName: "Chengdu", county: ["Chengdu", "chongzhou city ", "Jin Tang county"] },{ cityName: "Nanchong", county: ["Yi Long county", "Nan Bu county", "Ying shan county"]}, {province: "Beijing ", city: [{cityName: "Beijing", county: ["Dongcheng District", "Chaoyang District"]}] },{ province: "Anhui", city: [{cityName: "Anqing", county: ["Anqing City", "Huai Ning county", "Qian Shan county"] },{ cityName: "Bengbu", county: ["Bengbu City", "Gu Zhen county ", "Huaiyuan County"]}] var opt0 = ["Province", "prefecture-level city", "city, county, county"]; var selectID_arr2 = ["provinceid ", "cityid", "countyid"]; var province_index; window. onload = function () {// initialize the function init_select () {init_title (); init_province (); bind_province ();} // initialize the function init_title () {for (var k = 0; k
Html section