그누보드

다음주소 합산주소

헤롱헤롱이 2020. 5. 15. 15:11
<?
add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js
?>


<script>
$(document).ready(function(){
      $("#wr_101_3, #wr_101_4, #wr_102_3, #wr_102_4, #wr_103_3, #wr_103_4, #wr_104_3, #wr_104_4").keyup(function(event){
            autoAddress($(this).attr("id"));
      });
      $("#wr_101_3, #wr_101_4, #wr_102_3, #wr_102_4, #wr_103_3, #wr_103_4, #wr_104_3, #wr_104_4").click(function(event){
            autoAddress($(this).attr("id"));
      });
    $("#wr_101, #wr_102, #wr_103, #wr_104").datepicker({
        changeMonth: true,
        changeYear: true,
        dateFormat: "yy-mm-dd",
        showButtonPanel: true,
        yearRange: "c-99:c+99",
        minDate: "+3d;",
        maxDate: "+365d;"
    });
   
});
function autoAddress(id)
{
      daum.postcode.load(function(){
        new daum.Postcode({
            oncomplete: function(data) {
                  var fullAddr = data.address; // 최종 주소 변수
                var extraAddr = ''; // 조합형 주소 변수
                // 기본 주소가 도로명 타입일때 조합한다.
                if(data.addressType === 'R'){
                    //법정동명이 있을 경우 추가한다.
                    if(data.bname !== ''){
                        extraAddr += data.bname;
                    }
                    // 건물명이 있을 경우 추가한다.
                    if(data.buildingName !== ''){
                        extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
                    }
                    // 조합형주소의 유무에 따라 양쪽에 괄호를 추가하여 최종 주소를 만든다.
                    fullAddr += (extraAddr !== '' ? ' ('+ extraAddr +')' : '');
                }
                // 주소 정보를 해당 필드에 넣는다.
                document.getElementById(id).value = fullAddr;
            }
           
        }).open({
            popupName:'zipCodeWin'
        });
    });
}
</script>