-
Notifications
You must be signed in to change notification settings - Fork 1
/
select_onchangehandler.js
89 lines (84 loc) · 5.68 KB
/
select_onchangehandler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const onChangeHandler = () => {
const seoul = ['시/군/구','강남구', '강동구', '강북구','강서구','관악구','광진구','구로구','금천구','노원구','도봉구','동대문구','동작구','마포구','서대문구','서초구','성동구','성북구','송파구','양천구','영등포구','용산구','은평구','종로구','중구','중랑구']; // 8번째 줄 ~ 10번 째 줄은 array
const busan = ['시/군/구','강서구','금정구','기장군','남구','동구','동래구','부산진구','북구','사상구','사하구','서구','수영구','연제구','영도구','중구','해운대구'];
const daegu = ['시/군/구','남구','달서구','달성군','동구','북구','서구','수성구','중구'];
const incheon = ['시/군/구','강화군','계양구','남동구','동구','미추홀구','부평구','서구','연수구','옹진군','중구'];
const gwangju = ['시/군/구','광산구','남구','동구','북구','서구'];
const daejeon = ['시/군/구','대덕구','동구','서구','유성구','중구'];
const ulsan = ['시/군/구','남구','동구','북구','울주군','중구'];
const sejong = ['시/군/구', '--선택--'];
const gyoungi = ['시/군/구','가평군','고양시 덕양구','고양시 일산동구','고양시 일산서구','과천시','광명시','광주시','구리시','군포시','김포시','남양주시','동두천시','부천시','성남시 분당구',
'성남시 수정구','성남시 중원구','수원시 권선구','수원시 영통구','수원시 장안구','수원시 팔달구','시흥시','안산시 단원구','안산시 상록구','안성시','안양시 동안구','안양시 만안구','양주시','양평군','여주시','연천군','오산시','용인시 기흥구',
'용인시 수지구','용인시 처인구','의왕시','의정부시','이천시','파주시','평택시','포천시','하남시','화성시'];
const gwangwon = ['시/군/구','강릉시','고성군','동해시','삼척시','속초시','양구군','양양군','영월군','원주시','인제군','정선군','철원군','춘천시','태백시','평창군','홍청군','화천군','횡성군'];
const northchungcheong = ['시/군/구','괴산군','단양군','보은군','영동군','옥천군','음성군','제천시','증평군','진천군','청주시 상당구','청주시 서원구','청주시 청원구','청주시 흥덕구','충주시'];
const southchungcheong = ['시/군/구','계룡시','공주시','금산군','논산시','당진시','보령시','부여군','서산시','서천군','아산시','예산군','천안시 동남구','천안시 서북구','청양군','태안군','홍성군'];
const northjeonla = ['시/군/구','고창군','군산시','김제시','남원시','무주군','부안군','순창군','완주군','익산시','임실군','장수군','전주시 덕진구','전주시 완산구','정읍시','진안군'];
const southjeonla = ['시/군/구','강진군','고흥군','곡성군','광양시','구례군','나주시','담양군','목포시','무안군','보성군','순천시','신안군','여수시','영광군','영암군','완도군','장성군','장흥군','진도군','함평군','해남군','화순군'];
const northgyungsang = ['시/군/구','경산시','경주시','고령군','구미시','군위군','김천시','문경시','봉화군','상주시','성주군','안동시','영덕군','영양군','영주시','영천시','예천군','울릉군','울진군','의성군','청도군','청송군','칠곡군','포항시 남구','포항시 북구'];
const southgyungsang = ['시/군/구','거제시','거창군','고성군','김해시','남해군','밀양시','사천시','산청군','양산시','의령군','진주시','창녕군',
'창원시 마산합포구','창원시 마산회원구','창원시 성산구','창원시 의창구','창원시 진해구','통영시','하동군','함안군','함양군','합천군'];
const jeju = ['시/군/구','서귀포시','제주시'];
let temp = ['시/군/구'];
const _do = document.getElementById('do').value; //첫 번째 select의 value를 가져옴 -> 이의 변화에 따라 다른 select에 영향을 줌.
const _si = document.getElementById('si'); //영향을 받을 si select의 위치를 갖고옴.
if (_do == "서울특별시") {
temp = seoul;
} else if (_do == "부산광역시") {
temp = busan;
} else if (_do == "대구광역시") {
temp = daegu;
}
else if (_do == "인천광역시") {
temp = incheon;
}
else if (_do == "광주광역시") {
temp = gwangju;
}
else if (_do == "대전광역시") {
temp = daejeon;
}
else if (_do == "울산광역시") {
temp = ulsan;
}
else if (_do == "세종특별자치시") {
temp = sejong;
}
else if (_do == "경기도") {
temp = gyoungi;
}
else if (_do == "강원도") {
temp = gwangwon;
}
else if (_do == "충청북도") {
temp = northchungcheong;
}
else if (_do == "충청남도") {
temp = southchungcheong;
}
else if (_do == "전라북도") {
temp = northjeonla;
}
else if (_do == "전라남도") {
temp = southjeonla;
}
else if (_do == "경상북도") {
temp = northgyungsang;
}
else if (_do == "경상남도") {
temp = southgyungsang;
}
else if (_do == "제주특별자치도") {
temp = jeju;
}
//삭제 부분
while(_si.hasChildNodes())
{
_si.removeChild(_si.firstChild);
}
for (let idx = 0; idx < temp.length; idx++) {
const newOption = document.createElement('option');
newOption.innerHTML = temp[idx];
_si.appendChild(newOption); // si에 추가
}
};