-공식문서
https://postcode.map.daum.net/guide
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kakao API</title>
</head>
<body>
<table>
<tr>
<th>이름</th>
<td><input type="text" name="user_name"></td>
</tr>
<tr>
<th>주소</th>
<td><input type="text" id="address_kakao" name="address" readonly /></td>
</tr>
<tr>
<th>상세 주소</th>
<td><input type="text" name="address_detail" /></td>
</tr>
</table>
</body>
<script src="//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<script>
window.onload = function(){
document.getElementById("address_kakao").addEventListener("click", function(){ //주소입력칸을 클릭하면
//카카오 지도 발생
new daum.Postcode({
oncomplete: function(data) { //선택시 입력값 세팅
document.getElementById("address_kakao").value = data.address; // 주소 넣기
document.querySelector("input[name=address_detail]").focus(); //상세입력 포커싱
}
}).open();
});
}
</script>
</html>
window.onload = function(){
document.getElementById("objMBs1_05_01").addEventListener("click", function(){ //주소입력칸을 클릭하면
//카카오 지도 발생
new daum.Postcode({
oncomplete: function(data) { //선택시 입력값 세팅
var address = data.roadAddress + (data.buildingName ? " " + data.buildingName : ""); // 주소와 세부주소 합치기
document.getElementById("objMBs1_05_01").value = address; // 주소 및 세부주소 넣기
document.querySelector("input[name=objMBs1_05_01]").focus(); //상세입력 포커싱
}
}).open();
});
}