새주소 도로명주소 우편번호 검색 (다음API 활용하기) (2014-12-22 수정)
링크
http://www.happyjung.com/bbs/board.php?bo_table=lecture&wr_id=1260 (1136) http://postcode.map.daum.net/guide (978)
다음(DAUM)에서 제공하는 Open API 활용하기
우편번호 검색창을 아래의 내용을 참고해서 변경합니다.
다음 API 의 특징은 id 값으로만 검색결과를 가져와서 적용할수 있다는 것입니다.
즉, form 요소로 사용되는 name 정보만 사용하는 것으로 설정하면 된다는 것이죠.
< 용도 1 : 우편번호 + 도로명주소 + 참고항목 + 지번주소 >
<input type="text" name="post1" id="post1" value=""> - <input type="text" name="post2" id="post2" value="">
<input type="button" onclick="openDaumPostcode()" value="우편번호 찾기" style="width:100px; height:20px; font-size:11px; background-color:#ECECEC"><br>
<input type="text"name="addr1" id="addr" value="" title="행정기본주소" style="width:49%">
<input type="text" name="addr2" id="addr2" value="" title="상세주소" style="width:49%">
<input type="text" name="addr3" id="addr3" value="" title="참고항목" style="width:99%">
<input type="text" name="jibeon" id="jibeon" value="" title="지번주소" style="width:99%">
<script src="http://dmaps.daum.net/map_js_init/postcode.js"></script>
<script>
function openDaumPostcode() {
new daum.Postcode({
oncomplete: function(data) {
// 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.
// 우편번호와 주소 정보를 해당 필드에 넣고, 커서를 상세주소 필드로 이동한다.
document.getElementById('post1').value = data.postcode1;
document.getElementById('post2').value = data.postcode2;
document.getElementById('addr').value = data.address1;
document.getElementById('addr3').value = data.address2;
document.getElementById('jibeon').value = data.relatedAddress;
document.getElementById('addr2').focus();
}
}).open();
}
</script>
< 용도 2 : 우편번호 + 도로명주소 + 참고항목 >
<input type="text" name="post1" id="post1" value=""> - <input type="text" name="post2" id="post2" value="">
<input type="button" onclick="openDaumPostcode()" value="우편번호 찾기" style="width:100px; height:20px; font-size:11px; background-color:#ECECEC"><br>
<input type="text"name="addr1" id="addr" value="" title="행정기본주소" style="width:49%">
<input type="text" name="addr2" id="addr2" value="" title="상세주소" style="width:49%">
<script src="http://dmaps.daum.net/map_js_init/postcode.js"></script>
<script>
function openDaumPostcode() {
new daum.Postcode({
oncomplete: function(data) {
// 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.
// 우편번호와 주소 정보를 해당 필드에 넣고, 커서를 상세주소 필드로 이동한다.
document.getElementById('post1').value = data.postcode1;
document.getElementById('post2').value = data.postcode2;
document.getElementById('addr').value = data.address1;
document.getElementById('addr2').value = data.address2;
//document.getElementById('jibeon').value = data.relatedAddress;
document.getElementById('addr2').focus();
}
}).open();
}
</script>
우편번호 검색창을 아래의 내용을 참고해서 변경합니다.
다음 API 의 특징은 id 값으로만 검색결과를 가져와서 적용할수 있다는 것입니다.
즉, form 요소로 사용되는 name 정보만 사용하는 것으로 설정하면 된다는 것이죠.
< 용도 1 : 우편번호 + 도로명주소 + 참고항목 + 지번주소 >
<input type="text" name="post1" id="post1" value=""> - <input type="text" name="post2" id="post2" value="">
<input type="button" onclick="openDaumPostcode()" value="우편번호 찾기" style="width:100px; height:20px; font-size:11px; background-color:#ECECEC"><br>
<input type="text"name="addr1" id="addr" value="" title="행정기본주소" style="width:49%">
<input type="text" name="addr2" id="addr2" value="" title="상세주소" style="width:49%">
<input type="text" name="addr3" id="addr3" value="" title="참고항목" style="width:99%">
<input type="text" name="jibeon" id="jibeon" value="" title="지번주소" style="width:99%">
<script src="http://dmaps.daum.net/map_js_init/postcode.js"></script>
<script>
function openDaumPostcode() {
new daum.Postcode({
oncomplete: function(data) {
// 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.
// 우편번호와 주소 정보를 해당 필드에 넣고, 커서를 상세주소 필드로 이동한다.
document.getElementById('post1').value = data.postcode1;
document.getElementById('post2').value = data.postcode2;
document.getElementById('addr').value = data.address1;
document.getElementById('addr3').value = data.address2;
document.getElementById('jibeon').value = data.relatedAddress;
document.getElementById('addr2').focus();
}
}).open();
}
</script>
< 용도 2 : 우편번호 + 도로명주소 + 참고항목 >
<input type="text" name="post1" id="post1" value=""> - <input type="text" name="post2" id="post2" value="">
<input type="button" onclick="openDaumPostcode()" value="우편번호 찾기" style="width:100px; height:20px; font-size:11px; background-color:#ECECEC"><br>
<input type="text"name="addr1" id="addr" value="" title="행정기본주소" style="width:49%">
<input type="text" name="addr2" id="addr2" value="" title="상세주소" style="width:49%">
<script src="http://dmaps.daum.net/map_js_init/postcode.js"></script>
<script>
function openDaumPostcode() {
new daum.Postcode({
oncomplete: function(data) {
// 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.
// 우편번호와 주소 정보를 해당 필드에 넣고, 커서를 상세주소 필드로 이동한다.
document.getElementById('post1').value = data.postcode1;
document.getElementById('post2').value = data.postcode2;
document.getElementById('addr').value = data.address1;
document.getElementById('addr2').value = data.address2;
//document.getElementById('jibeon').value = data.relatedAddress;
document.getElementById('addr2').focus();
}
}).open();
}
</script>
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 85 |
사노라가노라
|
12년 전 | 11203 | |
| 84 |
사노라가노라
|
12년 전 | 6787 | |
| 83 |
사노라가노라
|
12년 전 | 19902 | |
| 82 |
사노라가노라
|
12년 전 | 14332 | |
| 81 | 12년 전 | 8842 | ||
| 80 |
사노라가노라
|
12년 전 | 14492 | |
| 79 | 12년 전 | 11410 | ||
| 78 |
사노라가노라
|
12년 전 | 7457 | |
| 77 | 12년 전 | 7490 | ||
| 76 | 12년 전 | 6588 | ||
| 75 | 12년 전 | 7756 | ||
| 74 | 12년 전 | 5596 | ||
| 73 | 12년 전 | 6745 | ||
| 72 | 12년 전 | 10228 | ||
| 71 | 12년 전 | 10567 | ||
| 70 | 12년 전 | 4411 | ||
| 69 | 12년 전 | 19280 | ||
| 68 | 12년 전 | 6266 | ||
| 67 | 12년 전 | 7261 | ||
| 66 | 12년 전 | 15164 | ||
| 65 | 12년 전 | 7068 | ||
| 64 |
letsgolee
|
12년 전 | 11416 | |
| 63 | 12년 전 | 27448 | ||
| 62 | 12년 전 | 8197 | ||
| 61 | 12년 전 | 7751 | ||
| 60 | 12년 전 | 7471 | ||
| 59 |
sbtech
|
12년 전 | 16397 | |
| 58 | 12년 전 | 6883 | ||
| 57 | 12년 전 | 5897 | ||
| 56 | 12년 전 | 5949 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기