개발일기/프로젝트 일기
HealthDuo-home 화면
존태
2022. 6. 28. 21:21
버튼 크기를 고정하기 위에 링크에서 나온 해결방법을 적용해봤으나 변하지 않았다.... 나중에 다시 고쳐봐야 겠다.
<script type="text/javascript">
let addressInfo = document.getElementById("addressInfo");
window.onload = async function () {
str = "";
asd = "";
let URL = "http://localhost:8080/findRegion"
let options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
}
let response = await fetch(URL, options)
let regionInfo = await response.json();
for (let i = 0; i < regionInfo.length; i++) {
if (i % 2 == 0 && i > 0) {
str += '<br>'
}
str += '<button class="btn-secondary btn-lg custom" value="button" onclick="nextRegion(\''+regionInfo[i]+'\')">' + regionInfo[i] + '</button>';
}
addressInfo.innerHTML = str;
}
async function nextRegion(region) {
addressInfo.innerHTML = " ";
str = "";
let URL = "http://localhost:8080/findCity"
let options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
region: region
})
}
let response = await fetch(URL, options)
let nextinfo = await response.json();
if (region == "서울특별시") {
for (let i = 0; i < nextinfo.length; i++) {
if (i % 2 == 0 && i > 0) {
str += '<br>'
}
str += '<button class="btn-secondary btn-lg custom" type="button" onclick="nextStreet(\''+ nextinfo[i] +'\')">' + nextinfo[i] + '</button>';
}
addressInfo.innerHTML = str;
} else {
for (let i = 0; i < nextinfo.length; i++) {
if (i % 2 == 0 && i > 0) {
str += '<br>'
}
str += '<button class="btn-secondary btn-lg custom" type="button" onclick="nextFullCity(\'' + nextinfo[i] +'\' )">' + nextinfo[i] + '</button>';
}
addressInfo.innerHTML = str;
}
}
async function nextFullCity(city) {
addressInfo.innerHTML = " ";
str = "";
let URL = "http://localhost:8080/findfullCity"
let options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
city: city
})
}
let response = await fetch(URL, options)
let nextinfo = await response.json();
for (let i = 0; i < nextinfo.length; i++) {
if (i % 2 == 0 && i > 0) {
str += '<br>'
}
str += '<button class="btn-secondary btn-lg custom" type="button" onclick="nextStreet(\''+ nextinfo[i] +'\')">' + nextinfo[i] + '</button>';
}
addressInfo.innerHTML = str;
}
async function nextStreet(fullCity) {
addressInfo.innerHTML = " ";
str = "";
let URL = "http://localhost:8080/findStreet"
let options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
fullCity: fullCity
})
}
let response = await fetch(URL, options)
let nextinfo = await response.json();
for (let i = 0; i < nextinfo.length; i++) {
if (i % 2 == 0 && i > 0) {
str += '<br>'
}
str += '<button class="btn-secondary btn-lg custom" type="button" onclick="location.href=\'bbsLists?address='+ nextinfo[i] + '\'">' + nextinfo[i] + '</button>';
}
addressInfo.innerHTML = str;
}
</script>
비동기 통신을 통해 지역에 대한 정보로 xx구에대한 정보를 찾고 구에대한 정보로 xx동의 정보를 얻는다. xx동을 클릭하게
되면 xx동에 해당되는 게시판이 보여진다.