function checkZip(){ var f = document.frm; if( f.zip.value.length == 3 ){ if( f.zip2.value.length != 4 ){ postal(); } else { postal(); /* $.get("../common/addr1.php", {"zip1":f.zip.value, "zip2":f.zip2.value, "addr_type":1}, function (data) { f.addr1.value = data.addr1; f.addr2.value = data.addr2; }, "json"); */ } } else { alert("郵便番号の先頭3桁以上を入力してください。"); } } function checkZip2(){ var f = document.frm; if( f.zip.value.length == 3 ){ if( f.zip2.value.length != 4 ){ postal(); } else { $.get("../common/addr1.php", {"zip1":f.zip.value, "zip2":f.zip2.value, "addr_type":2}, function (data) { f.addr1.value = data.addr1; checkCity(); f.addr2.value = data.addr2; f.addr3.value = data.addr3; }, "json"); } } else { alert("郵便番号の先頭3桁以上を入力してください。"); } } function checkCity(selected_item){ var f = document.frm; if( f.addr1.value == "" ){ return; } $.ajax({ type: "post", url: "../common/addr2.php", data: "pref=" + f.addr1.value, dataType: "json", async: false, success: function (data) { while( f.addr2.options.length > 1 ) { f.addr2.options[f.addr2.options.length-1] = null; } if(!data){ return; } for(var i = 0; i < data.length; i++){ f.addr2.options[i+1] = new Option(data[i], data[i]); if(data[i] == selected_item){ f.addr2.options[i+1].selected = true; } } } }); } function postal(){ var f = document.frm; var url = "../common/postal.php?fname=frm" + "&zip1=" + f.zip.value + "&zip2=" + f.zip2.value + "&txtzip1=zip" + "&txtzip2=zip2" + "&txtaddr1=addr1" + "&txtaddr2=addr2" + "&txtaddr3=addr3"; var size = "resizable=no,menubar=no,status=no,directories=no,toolbar=no,location=no,scrollbars=yes,width=450,height=400,top=0,left=50"; window.open(url,"_blank",size); } function setArea2(idx, set_frm){ var f = (set_frm) ? set_frm : document.frm; if(f.area1.value == ""){ return; } //var area2 = document.getElementById("area2"); var area2 = f.area2; while(area2.lastChild){ area2.removeChild(area2.lastChild); } var hash = g_arrArea2[f.area1.value]; for(var i in hash){ var opt = document.createElement("option"); opt.value = i; opt.selected = (i == idx) ? true : false; opt.appendChild(document.createTextNode(hash[i])); area2.appendChild(opt); } } function disp_cnt(obj, disp_id){ var rep = obj.value.replace(/\r\n/g, "\n"); //document.getElementById(disp_id).innerHTML = obj.value.length; document.getElementById(disp_id).innerHTML = rep.length; } var g_arrArea2 = []; g_arrArea2[1] = {'':'エリア選択の上、お選びください',1:'千代田区',2:'中央区',3:'港区',4:'新宿区',5:'文京区',6:'台東区',7:'墨田区',8:'江東区',9:'品川区',10:'目黒区',11:'大田区',12:'世田谷区',13:'渋谷区',14:'中野区',15:'杉並区',16:'豊島区',17:'北区',18:'荒川区',19:'板橋区',20:'練馬区',21:'足立区',22:'葛飾区',23:'江戸川区'}; g_arrArea2[2] = {'':'エリア選択の上、お選びください',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:'小笠原村'};