Preparations fo...LOGIN

Preparations for three-level linkage in JavaScript development

The front-end is done, and the next step is our JavaScript. Before writing, we need to define the array of provinces and cities we need, as shown below:

<script>
   //声明省
   var oProc = ["安徽","上海","山东"];  //直接声明array
   //声明市
   var oCity = [
       ["合肥","淮南","芜湖"],
       ["浦东","闵行","浦西"],
       ["济南","青岛","枣庄"]
   ];
   //声明区
   var oDist = [
       [
           ["政务区","庐阳区","蜀山区"],
           ["田家庵区","大通区","九龙岗区"],
           ["镜湖区","鸠江区","三山区"]
       ],
       [
           ["浦东1","浦东2","浦东3"],
           ["闵行1","闵行2","闵行3"],
           ["浦西1","浦西","浦西3"]
       ],
       [
           ["历下区","天桥区","长清区"],
           ["市南区","市北区","李沧区"],
           ["薛城区","市中区","峄城区"]
       ]
   ];
</script>

This is just a simple For example, when the actual work involves the whole province or the whole country, then the workload will be relatively large. This is what I call preparation work. But don’t worry, there will be examples written by other programmers, and we can just use them when the time comes. Just here to let everyone know.

Declare the province, city, and district in the form of an array, and then use it.

Next Section
<script> //声明省 var oProc = ["安徽","上海","山东"]; //直接声明array //声明市 var oCity = [ ["合肥","淮南","芜湖"], ["浦东","闵行","浦西"], ["济南","青岛","枣庄"] ]; //声明区 var oDist = [ [ ["政务区","庐阳区","蜀山区"], ["田家庵区","大通区","九龙岗区"], ["镜湖区","鸠江区","三山区"] ], [ ["浦东1","浦东2","浦东3"], ["闵行1","闵行2","闵行3"], ["浦西1","浦西","浦西3"] ], [ ["历下区","天桥区","长清区"], ["市南区","市北区","李沧区"], ["薛城区","市中区","峄城区"] ] ]; </script>
submitReset Code
ChapterCourseware