이렇게 하면 닫힌 div 태그 내의 위치에 다단계 연결 내용이 표시됩니다.
js 디자인 코드는 다음과 같습니다.
코드 복사 코드는 다음과 같습니다
//주소 데이터 정의 시작
var AddressTree={};
AddressTree["a_row"]=new Array(); //存所有记录
with(AddressTree){
a_row["1"]=["北京市",0,1];
a_row["2"]=["上海市",0,1];
a_row["3"]=["天津市",0,1];
a_row["4"]=["重庆市",0,1];
a_row["5"]=["河北",0,0];
a_row["6"]=["山西",0,0];
a_row["7"]=["内蒙古",0,0];
a_row["8"]=["辽宁",0,0];
a_row["9"]=["吉林",0,0];
a_row["10"]=["黑龙江",0,0];
a_row["11"]=["江苏",0,0];
a_row["12"]=["渐江",0,0];
a_row["13"]=["安徽",0,0];
a_row["14"]=["福建",0,0];
a_row["15"]=["江西",0,0];
a_row["16"]=["山东",0,0];
a_row["17"]=["河南",0,0];
a_row["18"]=["湖北",0,0];
a_row["19"]=["湖南",0,0];
a_row["20"]=["广东",0,0];
a_row["21"]=["广西",0,0];
a_row["22"]=["海南",0,0];
a_row["23"]=["四川",0,0];
a_row["24"]=["贵州",0,0];
a_row["25"]=["云南",0,0];
a_row["26"]=["西藏",0,0];
a_row["27"]=["陕西",0,0];
a_row["28"]=["甘肃",0,0];
a_row["29"]=["青海",0,0];
a_row["30"]=["宁夏",0,0];
a_row["31"]=["新壃",0,0];
a_row["32"]=["香港",0,1];
a_row["33"]=["澳门",0,1];
a_row["34"]=["台湾",0,0];
a_row["35"]=["石家庄",5,1];
a_row["36"]=["唐山",5,1];
a_row["37"]=["秦皇岛",5,1];
a_row["38"]=["邯郸",5,1];
a_row["39"]=["邢台",5,1];
a_row["40"]=["保定",5,1];
a_row["41"]=["张家口",5,1];
a_row["42"]=["承德",5,1];
a_row["43"]=["沧州",5,1];
a_row["44"]=["廊坊",5,1];
a_row["45"]=["衡水",5,1];
a_row["46"]=["太原",6,1];
a_row["47"]=["大同",6,1];
a_row["48"]=["阳泉",6,1];
a_row["49"]=["长治",6,1];
a_row["50"]=["晋城",6,1];
a_row["51"]=["朔州",6,1];
a_row["52"]=["晋中",6,1];
a_row["53"]=["运城",6,1];
a_row["54"]=["忻州",6,1];
a_row["55"]=["临汾",6,1];
a_row["56"]=["吕梁",6,1];
a_row["58"]=["呼和浩特",7,1];
a_row["59"]=["包头",7,1];
a_row["60"]=["乌海",7,1];
a_row["61"]=["赤峰",7,1];
a_row["62"]=["通辽",7,1];
a_row["63"]=["鄂尔多斯",7,1];
a_row["64"]=["呼伦贝尔",7,1];
a_row["65"]=["乌兰察布市",7,1];
a_row["66"]=["锡林郭勒盟",7,1];
a_row["67"]=["巴彦淖尔盟",7,1];
a_row["68"]=["阿拉善盟",7,1];
a_row["69"]=["兴安盟",7,1];
a_row["70"]=["沈阳",8,1];
a_row["71"]=["大连",8,1];
a_row["72"]=["鞍山",8,1];
a_row["73"]=["抚顺",8,1];
a_row["74"]=["本溪",8,1];
a_row["75"]=["丹东",8,1];
a_row["76"]=["锦州",8,1];
a_row["77"]=["葫芦岛",8,1];
a_row["78"]=["营口",8,1];
a_row["79"]=["盘锦",8,1];
a_row["80"]=["阜新",8,1];
a_row["81"]=["辽阳",8,1];
a_row["82"]=["铁岭",8,1];
a_row["83"]=["朝阳",8,1];
a_row["84"]=["长春",9,1];
a_row["85"]=["吉林",9,1];
a_row["86"]=["四平",9,1];
a_row["87"]=["辽源",9,1];
a_row["88"]=["通化",9,1];
a_row["89"]=["白山",9,1];
a_row["90"]=["松原",9,1];
a_row["91"]=["白城",9,1];
a_row["92"]=["延办朝鲜族自治州",9,1];
a_row["93"]=["哈尔滨",10,1];
a_row["94"]=["齐齐哈尔",10,1];
a_row["95"]=["鹤岗",10,1];
a_row["96"]=["双鸭山",10,1];
a_row["97"]=["鸡西",10,1];
a_row["98"]=["大庆",10,1];
a_row["99"]=["伊春",10,1];
a_row["100"]=["牡丹江",10,1];
a_row["101"]=["佳木斯",10,1];
a_row["102"]=["七台河",10,1];
a_row["103"]=["黑河",10,1];
a_row["104"]=["绥化",10,1];
a_row["105"]=["大兴安岭",10,1];
a_row["106"]=["南京",11,1];
a_row["107"]=["无锡",11,1];
a_row["108"]=["徐州",11,1];
a_row["109"]=["常州",11,1];
a_row["110"]=["苏州",11,1];
a_row["111"]=["南通",11,1];
a_row["112"]=["连云港",11,1];
a_row["113"]=["淮安",11,1];
a_row["114"]=["盐城",11,1];
a_row["115"]=["扬州",11,1];
a_row["116"]=["镇江",11,1];
a_row["117"]=["泰州",11,1];
a_row["118"]=["宿迀",11,1];
a_row["119"]=["杭州",12,1];
a_row["120"]=["宁波",12,1];
a_row["121"]=["温州",12,1];
a_row["122"]=["嘉兴",12,1];
a_row["123"]=["湖州",12,1];
a_row["124"]=["绍兴",12,1];
a_row["125"]=["金华",12,1];
a_row["126"]=["舟山",12,1];
a_row["127"]=["台州",12,1];
a_row["128"]=["丽水",12,1];
a_row["129"]=["衢州",12,1];
a_row["130"]=["合肥",13,1];
a_row["131"]=["芜湖",13,1];
a_row["132"]=["蚌埠",13,1];
a_row["133"]=["淮南",13,1];
a_row["134"]=["马鞍山",13,1];
a_row["135"]=["淮北",13,1];
a_row["136"]=["铜陵",13,1];
a_row["137"]=["安庆",13,1];
a_row["138"]=["黄山",13,1];
a_row["139"]=["滁州",13,1];
a_row["140"]=["阜阳",13,1];
a_row["141"]=["宿州",13,1];
a_row["142"]=["巢湖",13,1];
a_row["143"]=["六安",13,1];
a_row["144"]=["毫州",13,1];
a_row["145"]=["池州",13,1];
a_row["146"]=["宣城",13,1];
a_row["147"]=["福州",14,1];
a_row["148"]=["厦门",14,1];
a_row["149"]=["莆田",14,1];
a_row["150"]=["三明",14,1];
a_row["151"]=["泉州",14,1];
a_row["152"]=["漳州",14,1];
a_row["153"]=["南平",14,1];
a_row["154"]=["龙岩",14,1];
a_row["155"]=["宁德",14,1];
a_row["156"]=["南昌",15,1];
a_row["157"]=["景德镇",15,1];
a_row["158"]=["萍乡",15,1];
a_row["159"]=["新余",15,1];
a_row["160"]=["九江",15,1];
a_row["161"]=["鹰潭",15,1];
a_row["162"]=["吉安",15,1];
a_row["163"]=["宜春",15,1];
a_row["164"]=["抚州",15,1];
a_row["165"]=["上饶",15,1];
a_row["166"]=["赣州",15,1];
a_row["167"]=["济南",16,1];
a_row["168"]=["青岛",16,1];
a_row["169"]=["淄博",16,1];
a_row["170"]=["枣庄",16,1];
a_row["171"]=["东营",16,1];
a_row["172"]=["潍坊",16,1];
a_row["173"]=["烟台",16,1];
a_row["174"]=["威海",16,1];
a_row["175"]=["济宁",16,1];
a_row["176"]=["泰安",16,1];
a_row["177"]=["日照",16,1];
a_row["178"]=["莱芜",16,1];
a_row["179"]=["德州",16,1];
a_row["180"]=["临沂",16,1];
a_row["181"]=["聊城",16,1];
a_row["182"]=["滨州",16,1];
a_row["183"]=["菏泽",16,1];
a_row["184"]=["郑州",17,1];
a_row["185"]=["开封",17,1];
a_row["186"]=["洛阳",17,1];
a_row["187"]=["平顶山",17,1];
a_row["188"]=["焦作",17,1];
a_row["189"]=["鹤壁",17,1];
a_row["190"]=["新乡",17,1];
a_row["191"]=["安阳",17,1];
a_row["192"]=["濮阳",17,1];
a_row["193"]=["许昌",17,1];
a_row["194"]=["漯河",17,1];
a_row["195"]=["三门峡",17,1];
a_row["196"]=["南阳",17,1];
a_row["197"]=["南丘",17,1];
a_row["198"]=["信阳",17,1];
a_row["199"]=["周口",17,1];
a_row["200"]=["驻马店",17,1];
a_row["201"]=["济源",17,1];
a_row["202"]=["武汉",18,1];
a_row["203"]=["黄石",18,1];
a_row["204"]=["襄樊",18,1];
a_row["205"]=["十堰",18,1];
a_row["206"]=["荆州",18,1];
a_row["207"]=["宜昌",18,1];
a_row["208"]=["荆门",18,1];
a_row["209"]=["鄂州",18,1];
a_row["210"]=["孝感",18,1];
a_row["211"]=["黄冈",18,1];
a_row["212"]=["咸宁",18,1];
a_row["213"]=["随州",18,1];
a_row["214"]=["仙桃",18,1];
a_row["215"]=["天门",18,1];
a_row["216"]=["潜江",18,1];
a_row["217"]=["神农架",18,1];
a_row["218"]=["恩施土家族自治州",18,1];
a_row["219"]=["长沙",19,1];
a_row["220"]=["株洲",19,1];
a_row["221"]=["湘潭",19,1];
a_row["222"]=["衡阳",19,1];
a_row["223"]=["邵阳",19,1];
a_row["224"]=["岳阳",19,1];
a_row["225"]=["常德",19,1];
a_row["226"]=["张家界",19,1];
a_row["227"]=["益阳",19,1];
a_row["228"]=["郴州",19,1];
a_row["229"]=["怀化",19,1];
a_row["230"]=["娄底",19,1];
a_row["231"]=["湘西土家族苗族自治州",19,1];
a_row["232"]=["广州",20,1];
a_row["233"]=["深圳",20,1];
a_row["234"]=["珠海",20,1];
a_row["235"]=["汕头",20,1];
a_row["236"]=["韶关",20,1];
a_row["237"]=["佛山",20,1];
a_row["238"]=["江门",20,1];
a_row["239"]=["湛江",20,1];
a_row["240"]=["茂名",20,1];
a_row["241"]=["肇庆",20,1];
a_row["242"]=["惠州",20,1];
a_row["243"]=["梅州",20,1];
a_row["244"]=["汕尾",20,1];
a_row["245"]=["河源",20,1];
a_row["246"]=["阳江",20,1];
a_row["247"]=["清远",20,1];
a_row["248"]=["东莞",20,1];
a_row["249"]=["中山",20,1];
a_row["250"]=["潮州",20,1];
a_row["251"]=["揭阳",20,1];
a_row["252"]=["云浮",20,1];
a_row["253"]=["南宁",21,1];
a_row["254"]=["柳州",21,1];
a_row["255"]=["桂林",21,1];
a_row["256"]=["梧州",21,1];
a_row["257"]=["北海",21,1];
a_row["258"]=["防城港",21,1];
a_row["259"]=["钦州",21,1];
a_row["260"]=["贵港",21,1];
a_row["261"]=["玉林",21,1];
a_row["262"]=["百色",21,1];
a_row["263"]=["贺州",21,1];
a_row["264"]=["河池",21,1];
a_row["265"]=["来宾",21,1];
a_row["266"]=["崇左",21,1];
a_row["267"]=["海口",22,1];
a_row["268"]=["三亚",22,1];
a_row["269"]=["五指山",22,1];
a_row["270"]=["琼海",22,1];
a_row["271"]=["儋州",22,1];
a_row["272"]=["文昌",22,1];
a_row["273"]=["方宁",22,1];
a_row["274"]=["东方",22,1];
a_row["275"]=["澄迈",22,1];
a_row["276"]=["定安",22,1];
a_row["277"]=["屯昌",22,1];
a_row["278"]=["临高",22,1];
a_row["279"]=["白沙黎族自治县",22,1];
a_row["280"]=["江黎族自治县",22,1];
a_row["281"]=["乐东黎族自治县",22,1];
a_row["282"]=["陵水黎族自治县",22,1];
a_row["283"]=["保亭黎族苗族自治县",22,1];
a_row["284"]=["琼中称许苗族自治县",22,1];
a_row["285"]=["成都",23,1];
a_row["286"]=["自贡",23,1];
a_row["287"]=["攀枝花",23,1];
a_row["288"]=["泸州",23,1];
a_row["289"]=["德阳",23,1];
a_row["290"]=["면양",23,1];
a_row["291"]=["Guangyuan",23,1]
a_row["292"]=["쑤이닝 ",23,1];
a_row["293"]=["Neijiang",23,1];
a_row["294"]=["러산",23,1];
a_row["295"]=["Nanchong",23,1];
a_row["296"]=["Yibin",23,1]
a_row["297"]=["광 'an ",23,1];
a_row["298"]=["Dazhou",23,1];
a_row["299"]=["Meishan",23,1];
a_row["300"]=["Ya'an",23,1];
a_row["301"]=["Bazhong",23,1]
a_row["302"] =[" Ziyang",23,1];
a_row["303"]=["Aba Tibetan and Qiang Autonomous Province",23,1]
a_row["304"]=["Ganzi Tibetan 자치주",23, 1];
a_row["305"]=["량산 이족 자치주",23,1];
a_row["306"]=["귀양",24,1 ];
a_row[ "307"]=["Liupanshui",24,1]
a_row["308"]=["Zunyi",24,1]; ]=["안순", 24,1];
a_row["310"]=["동인",24,1]
a_row["311"]=["비제",24,1 ];
a_row[ "312"]=["첸둥난 부의족 자치주",24,1]
a_row["313"]=["첸둥난 먀오족 자치주",24,1];
a_row["314 "]=["첸난 부의족 자치주",24,1]
a_row["315"]=["쿤밍",25,1]
a_row[ "316"]=[" 취징",25,1];
a_row["317"]=["위시",25,1]
a_row["318"]=["바오산", 25,1];
a_row["319"]=["Zhaotong",25,1];
a_row["320"]=["Lijiang",25,1]; "321"]=[" Simao",25,1];
a_row["322"]=["Jiancang",25,1]
a_row["323"]=["Wenshan Zhuang 및 먀오족 자치주",25,1 ];
a_row["324"]=["홍허 하니 및 이족 자치주",25,1];
a_row["325"]=["시솽반나 다이 자치주 현",25,1];
a_row["326"]=["추웅 이족 자치주",25,1];
a_row["327"]=["다리바이 자치주",25 ,1];
a_row["328" ]=["덕홍다이 및 징포자치주",25,1]
a_row["329"]=["누장리수자치주",25,1 ];
a_row["330"] =["디칭 티베트 자치주",25,1]
a_row["331"]=["라사",26,1]; "332"]=["나그쿠",26 ,1];
a_row["333"]=["참도",26,1]
a_row["334"]=["샤난", 26,1];
a_row[" 335"]=["Shigatse",26,1];
a_row["336"]=["Ali",26,1]; "337"]=["Lingzhi",26 ,1]
a_row["338"]=["시안",27,1]
a_row["339"]=["퉁촨 ",27,1];
a_row[" 340"]=["Baoji",27,1];
a_row["341"]=["Xianyang",27,1];
a_row["342"]=["Weinan",27 ,1];
a_row["343"]=["Yan'an",27,1]
a_row["344"]=[ "한중",27,1];
a_row[" 345"]=["율린",27,1]
a_row["346"]=["안캉",27,1]; 🎜>a_row["347"]=["상뤄",27 ,1];
a_row["348"]=["란저우",28,1]
a_row["349"]=[ "Jinchang",28,1];
a_row[" 350"]=["silver",28,1]
a_row["351"]=["Tianshui",28,1]; 🎜>a_row["352"]=["Jiayuguan",28 ,1];
a_row["353"]=["Wuwei",28,1]
a_row["354"]=[ "장계",28,1];
a_row[" 355"]=["핑량",28,1]
a_row["356"]=["사취안",28,1]; 🎜>a_row["357"]=["Qingyang" ,28,1];
a_row["358"]=["Dingxi",28,1]
a_row["359"]=[ "롱난",28,1];
a_row ["360"]=["린샤 회족 자치주",28,1]
a_row["361"]=["간난 티베트 자치주", 28,1];
a_row["362"]= ["시닝",29,1];
a_row["363"]=["하이동",29,1]; "364"]=["하이베이 티베트 자치주",29, 1]
a_row["365"]=["황난 티베트 자치주",29,1]
a_row["366"] =["하이난 티베트 자치주",29,1]
a_row["367"]=["고뤄 티베트 자치주",29,1]
a_row["368"]=["위슈 티베트 자치주",29,1];
a_row["369 "]=["하이몽고 티베트 자치주",29,1];
a_row["370"]=["인촨",30 ,1];
a_row["371"]=["시즈이샨 ",30,1]
a_row["372"]=["Wuzhong",30,1]; 373"]=["구위안",30,1];
a_row["374"]=["우루무치",31,1];
a_row["375"]=["카라마이",31 ,1];
a_row["376"]=["Shihezi ",31,1]
a_row["377"]=["Alar",31,1]; 378"]=["Tumushuk",31,1] ;
a_row["379"]=["Wujiaqu",31,1];
a_row["380"]=["툴루",31 ,1];
a_row[" 381"]=["하미",31,1]
a_row["382"]=["Hotian",31,1]; 383"]=["Aksu",31 ,1];
a_row["384"]=["카슈가르",31,1];
a_row["385"]=["키질수 키르기즈 자치주 ",31,1];
a_row["386"]=["Bayingoleng 몽골 자치주",31,1];
a_row["387"]=["창지 회족 자치주",31, 1];
a_row ["388"]=["보르탈라 몽골 자치주",31,1]
a_row["389"]=["일리 카자흐족 자치주",31,1]
a_row["390 "]=["타이베이",34,1];
a_row["391"]=["가오슝",34,1]
a_row["392"]=[ "지룽",34, 1];
a_row["393"]=["타이중",34,1]
a_row["394"]=["타이난",34,1]; 🎜>a_row["395 "]=["신주",34,1];
a_row["396"]=["자이",34,1]
a_row["397"]=[ "sss",285, 1];
}
var j=0;
AddressTree["a_record"]=new Array();//저장소 레코드 번호
for(AddressTree의 i[ "a_row"] ){AddressTree["a_record"][j ]=i;}
AddressTree.ObjNumber=1;
//주소 선택 생성자
function LightManAddressTree(){
var Data = AddressTree; //데이터 레코드 데이터 변수
this.noselectshow=["- - 도를 선택해주세요--","--시를 선택해주세요--","--구, 군을 선택해주세요--"];//각 레벨의 표시값을 선택하지 마세요
이. grade=0; //등급 번호
this.idvalue=0; //주소 선택 값의 ID 번호
this.text=""; //주소 문자열
this.listseparator=" " ; //주소 문자열에서 구분 기호
this.selectName="a_tree" (AddressTree.ObjNumber ) "_"
//주소 데이터 정의 끝
this.getfontpath = function(id) //지정된 레코드 번호의 상위 가져오기 Path
var path = "",upid
try{
upid=(isNaN(id)?0:id)
while(upid! =0){
var upid= Data["a_row"][upid][1]
If(path!="")path=upid "," path;else path=upid; }
}
catch( e){};
return eval("[" path "]")
}
//다음 목록 생성
this.selectshowlevel= function(obj,upid,def){
var selectobj,optionobj,havedef;
selectobj=document.getElementById(this.selectName this.grade)
if(selectobj){
document.getElementById (this.selectName this.grade).options.length=0;
}else{
selectobj=document.createElement("select")
selectobj.id=this.selectName
selectobj.grade=this.grade;
selectobj.obj=this;
selectobj.onchange=function(){
if(this.options[this.selectedIndex].value!="") {
this.obj.selectshow(obj ,this[this.selectedIndex].value); .obj.grade-1;i ){
var df=document.getElementById(this.obj.selectName i);
df.options.length=0;
defaultoption(this.obj,df, i);
🎜> }
defaultoption(this,selectobj, this.grade)
// 레벨의 데이터 표시
if(upid>=0){
for(var j=0;j thisrecord=Data["a_row"] [Data["a_record"][j]];
if(thisrecord[1]==upid){
optionobj=document.createElement("option")
optionobj.text=thisrecord[0 ];
optionobj.value=Data["a_record"][j];
selectobj.options.add(optionobj)
if(def==Data ["a_record"][j]) havedef =true;
}
}
}
if(havedef)selectobj.value=def
return selectobj;
this.selectshow = function(obj,id){ //显示选中记录号
var selectobj,optionobj,thisrecord;
var lastgrade,tempid=id,tempgrade;
var fontpath=this.getfontpath(id);
tempgrade=this.grade;
this.grade=0;
//显示选中前分内容
for (var i=0;i if(!document.getElementById(this.selectName this.grade)){
if(i this.Add(obj,this.selectshowlevel(obj,fontpath[i],fontpath[i 1]));
else
this.Add(obj,this.selectshowlevel(obj,fontpath[i],id));
}
this.grade ;
}
//显示选中后부분内容
do{
lastgrade=this.selectshowlevel(obj,tempid);
tempid=lastgrade.value;
if (tempid=="")tempid=-1;
this.Add(obj,lastgrade);
this.grade ;
}
while(lastgrade.options.length>0);
//删除多余选项
for(i=this.grade-1;i obj.removeChild(document.getElementById(this.selectName i));
}
//最得值
getvalue(this);
}
this.Add=function(obj,s){
if(s.options.length>0&&!document.getElementById(s.id))obj.appendChild(s);
}
//获取选择值
function getvalue(obj){
var sel
obj.text="";
obj.idvalue=0;
for(var i=0;i sel=document.getElementById(obj.selectName i);
if(sel.value!=""){
obj.text =(obj.text.match("\S")==null?"":obj.listseparator) sel.options[sel. selectedIndex].text;
obj.idvalue=sel.options[sel.selectedIndex].value;
}else{break;}
}
}
//级别显示数据
function defaultoption(obj,sobj,g){
시도{ . noselectshow[g]){
optionobj=document.createElement("option");
optionobj.text=obj.noselectshow[g];
optionobj.value="";
sobj.options.add(optionobj,0);
}
}
catch(e){}
}
}
address_test.htm
"http://www.w3.org/TR/html4/loose.dtd">
<머리>
제목 없는 문서
<본문>