基于JSON级联查询(修改)省 市 区
来源:互联网 发布:java junit4 编辑:程序博客网 时间:2024/05/01 00:31
基于JSON级联查询(修改)省 市 区
写了两个例子(1.选择省市区操着,2.在已选好省市区的情况下修改地址)
需要完整的json 可以点击下载
写了两个例子(1.选择省市区操着,2.在已选好省市区的情况下修改地址)
需要完整的json 可以点击下载
1.选择省市区(可直接运行)
===============选择省市区(复制运行)=================
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>基于JSON级联查询地区</title><script type="text/javascript">var country=[{"id":1,"parentId":0,"name":"中国","type":0}];var p=[{"id":2,"parentId":1,"name":"北京市","type":1},{"id":3,"parentId":1,"name":"安徽省","type":1}];var c=[{"id":37,"parentId":3,"name":"蚌埠","type":2},{"id":38,"parentId":2,"name":"北京","type":2}];var a=[{"id":398,"parentId":37,"name":"迎江区","type":3},{"id":399,"parentId":38,"name":"西城","type":3}];window.onload=function(){var province=document.getElementById("province"); for(temp in p){province.add(new Option(p[temp].name,p[temp].id));}}function setCity(){var city=document.getElementById("city");var area=document.getElementById("area");var val=document.getElementById("province").value;city.length=1;area.length=1;for(temp in c){ if(parseInt(c[temp].parentId) == parseInt(val) ){city.add(new Option(c[temp].name,c[temp].id));}} }function setArea(){var area=document.getElementById("area");var val=document.getElementById("city").value;area.length=1;for(temp in a){ if(parseInt(a[temp].parentId) == parseInt(val) ){area.add(new Option(a[temp].name,a[temp].id));}} }</script></head><body><select id="province" onChange="setCity()"> <option value="">--选择省会--</option></select><select id="city" onChange="setArea()"> <option value="">--选择城市--</option></select><select id="area"> <option value="">--选择区域--</option></select></body></html>
=======================修改选择地区(复制运行)=======================
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>基于JSON级联修改地区</title><script type="text/javascript">var country=[{"id":1,"parentId":0,"name":"中国","type":0}];var p=[{"id":2,"parentId":1,"name":"北京市","type":1},{"id":3,"parentId":1,"name":"安徽省","type":1}];var c=[{"id":37,"parentId":3,"name":"蚌埠","type":2},{"id":38,"parentId":2,"name":"北京","type":2}];var a=[{"id":398,"parentId":37,"name":"迎江区","type":3},{"id":399,"parentId":38,"name":"西城","type":3}];window.onload=function(){var province=document.getElementById("province");var city=document.getElementById("city");var area=document.getElementById("area");var ps=document.getElementById("province").value;var cs=document.getElementById("city").value;var as=document.getElementById("area").value;for(temp in p){ if(ps!=p[temp].id){province.add(new Option(p[temp].name,p[temp].id));}}for(temp in c){ if(cs!=c[temp].id && c[temp].parentId==ps){city.add(new Option(c[temp].name,c[temp].id));}} for(temp in a){ if(as!=a[temp].id && a[temp].parentId==cs){area.add(new Option(a[temp].name,a[temp].id));}} }function setCity(){var city=document.getElementById("city");var area=document.getElementById("area");var val=document.getElementById("province").value;city.length=1;area.length=1;var index=city.selectedIndex;var indexarea=area.selectedIndex;city.options.remove(index);area.options.remove(indexarea);city.add(new Option("--选择城市--",""));area.add(new Option("--选择区域--",""));for(temp in c){ if(parseInt(c[temp].parentId) == parseInt(val) ){city.add(new Option(c[temp].name,c[temp].id)); }} }function setArea(){var area=document.getElementById("area");var val=document.getElementById("city").value;area.length=1;var indexarea=area.selectedIndex;area.options.remove(indexarea);area.add(new Option("--选择区域--",""));for(temp in a){ if(parseInt(a[temp].parentId) == parseInt(val) ){area.add(new Option(a[temp].name,a[temp].id));}} }</script></head><body><select id="province" onChange="setCity()"> <option value="3">安徽省</option></select><select id="city" onChange="setArea()"> <option value="44">黄山</option></select><select id="area"> <option value="457">徽州区</option></select></body></html>
阅读全文
1 0
- 基于JSON级联查询(修改)省 市 区
- struts2+json+jquery 级联查询
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- 实现基于json的级联菜单
- Android——PageView轮播实现
- Adapter基础讲解-MVC模式的简单理解和Adapter概念解析
- Software Install for CentOS 7.3
- csdn如何转载别人的文章
- java连接不上hbase无异常信息
- 基于JSON级联查询(修改)省 市 区
- Detection物体检测及分类方法总结(RFCN/SSD/RCNN/FastRCNN/FasterRCNN/SPPNet/DPM/OverFeat/YOLO)
- The study of iterator in Python(20170912)
- python判断jpeg图片的完整性
- Java必备面试题
- SSM整合步骤
- Mybatis的批量处理标签使用场景
- ajax提交表单或者其他数据的时候能拿到结果但是还是会走errot分支
- 如何选出优秀的竞品,进行分析