<!-- Zip_Search.asp -->
<!--#include file="dbcon.inc"-->
<%
response.charset = "euc-kr"
set rs = server.CreateObject("adodb.recordset")
sql = "select distinct sido from tb_zip order by sido "
rs.open sql, db, 1
%>
<script>
var ajax_gugun;
function get_gugun_list(sido)
{
ajax_gugun = new ActiveXObject("Microsoft.XMLHTTP");
ajax_gugun.onreadystatechange = get_gugun_list_callback;
ajax_gugun.open("GET", "Zip_GugunList.asp?sido=" + sido, true);
ajax_gugun.send();
}
function get_gugun_list_callback()
{
if(ajax_gugun.readyState == 4){
if(ajax_gugun.status == 200){
if(typeof(document.all.div_gugun) == "object"){
document.all.div_gugun.innerHTML = ajax_gugun.responseText;
}
}
}
}
var ajax_addr;
function get_addr_list(){
var sido, gugun, dong;
sido = document.frmZip.sido.value;
gugun = document.frmZip.gugun.value;
dong = document.frmZip.dong.value;
if (dong.length < 2) return false;
ajax_addr = new ActiveXObject("Microsoft.XMLHTTP");
ajax_addr.onreadystatechange = get_addr_list_callback;
ajax_addr.open("GET", "Zip_AddrList.asp?sido=" + sido + "&gugun=" + gugun + "&dong=" + dong, true);
ajax_addr.send();
}
function get_addr_list_callback()
{
if(ajax_addr.readyState == 4){
if(ajax_addr.status == 200){
if(typeof(document.all.div_zip_list) == "object"){
if(ajax_addr.responseText.length > 0){
document.all.div_zip_list.style.display = "";
document.all.div_zip_list.innerHTML = ajax_addr.responseText;
}
else
document.all.div_zip_list.style.display = "none";
}
}
}
}
</script>
<style>
input, select, td { font-family:tahoma;font-size:9pt; }
</style>
<table border="0" cellpadding="4" cellspacing="0" width="400">
<form name="frmZip">
<tr>
<td>
<select name="sido" onChange="get_gugun_list(this.value);">
<option value="">시도선택</option>
<% Do Until rs.eof %>
<option value="<%=rs("sido")%>" ><%=rs("sido")%></option>
<%
rs.movenext
Loop
rs.close
Set rs = Nothing
%>
</select>
</td>
<td>
<div id="div_gugun">
<select name="gugun" >
<option value="">구/군선택</option>
</select>
</div>
</td>
<td>
동이름 : <input type="text" name="dong" style="width:50">
<input type="button" value="검색" onClick="get_addr_list();" style="width:40;border-style:solid;border-width:1">
</td>
</tr>
<tr>
<td colspan="3" align="center">
동이름을 입력하시오(2글자 이상)<br>
(예 : 논현, 구의1동, .. )
</td>
</tr>
</form>
</table>
<div id="div_zip_list" style="display:none;overflow-y:scroll; height:300;width:400"></div>
<!-- Zip_GugunList.asp -->
<!-- #include file="dbcon.inc"-->
<%
response.charset = "euc-kr"
sido = request("sido")
sql = "select distinct gugun from tb_zip where sido = '" & sido & "' order by gugun"
Set rs = server.CreateObject("adodb.recordset")
rs.open sql, db, 1
%>
<select name="gugun" >
<option value="">구/군선택</option>
<% Do Until rs.eof %>
<option value="<%=rs("gugun")%>" ><%=rs("gugun")%></option>
<%
rs.movenext
Loop
rs.close
Set rs = Nothing
%>
</select>
<!-- Zip_AddrList.asp -->
<!--#include file="dbcon.inc"-->
<%
response.charset = "euc-kr"
sido = request("sido")
gugun = request("gugun")
dong = request("dong")
If sido = "" And gugun = "" Then
sql = "select zipcode, sido, gugun, dong, ri, build, addr from tb_zip where dong like '%" & dong & "%'"
ElseIf sido <> "" And gugun = "" Then
sql = "select zipcode, sido, gugun, dong, ri, build, addr from tb_zip where sido = '" & sido & "' and dong like '%" & dong & "%'"
ElseIf sido <> "" And gugun <> "" Then
sql = "select zipcode, sido, gugun, dong, ri, build, addr from tb_zip where sido = '" & sido & "' and gugun = '" & gugun & "' and dong like '%" & dong & "%'"
End If
Set rs = server.CreateObject("adodb.recordset")
rs.open sql, db, 1
%>
<table cellpadding="3" cellspacing="3" border="1" width="400">
<%
Do Until rs.eof
zip = "[" & Left(rs("zipcode"), 3) & "-" & Right(rs("zipcode"), 3) & "]"
%>
<tr>
<td>
<a href="#"><%=zip%> </a>
</td>
<td>
<%=rs("addr")%>
</td>
</tr>
<%
rs.movenext
Loop
%>
</table>
':::: 개발 :::: > ::: A S P :::' 카테고리의 다른 글
클릭 한것 체크 쿠키에 저장하기 (0) | 2014.12.10 |
---|---|
asp 모든 세션 루프로 출력하기 (0) | 2014.12.01 |
dext upload 참고 (0) | 2014.11.12 |
JSP Split 메소드 이용 하여 문자 자르기 트 (0) | 2010.06.22 |
[본문스크랩] [Ajax]간단한 팝업메뉴 비동기 호출하기 (0) | 2009.12.28 |
[본문스크랩] ASP 내장함수 (0) | 2009.12.28 |
[본문스크랩] Formatcurrency (0) | 2009.12.28 |
[본문스크랩] Request와 Response 객체 활용 (1) | 2009.12.28 |