001.
<%
002.
003.
004.
Option
Explicit
005.
006.
Dim
Conn,strSQL,objRec,intRows
007.
Set
Conn = Server.Createobject(
"ADODB.Connection"
)
008.
Conn.Open
"DRIVER=Microsoft Access Driver (*.mdb);DBQ="
& Server.MapPath(
"db/thailand.mdb"
),
""
,
""
009.
%>
010.
<html>
011.
<head>
012.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=tis-620"
>
013.
<title>ThaiCreate.Com ListMenu</title>
014.
<script language =
"JavaScript"
>
015.
016.
//**** List Province (Start) ***//
017.
function ListProvince(SelectValue)
018.
{
019.
frmMain.ddlProvince.length = 0
020.
frmMain.ddlAmphur.length = 0
021.
022.
//*** Insert null
Default
Value ***//
023.
var myOption = new
Option
(
024.
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
025.
026.
<%
027.
strSQL =
"SELECT * FROM province ORDER BY PROVINCE_ID ASC "
028.
Set
objRec = Server.CreateObject(
"ADODB.Recordset"
)
029.
objRec.Open strSQL, Conn, 1,3
030.
031.
intRows = 0
032.
While
Not
objRec.EOF
033.
intRows = intRows + 1
034.
%>
035.
x = <%=intRows%>;
036.
mySubList = new Array();
037.
038.
strGroup = <%=objRec.Fields(
"GEO_ID"
).Value%>;
039.
strValue =
"<%=objRec.Fields("
PROVINCE_ID
").Value%>"
;
040.
strItem =
"<%=objRec.Fields("
PROVINCE_NAME
").Value%>"
;
041.
mySubList[x,0] = strItem;
042.
mySubList[x,1] = strGroup;
043.
mySubList[x,2] = strValue;
044.
if (mySubList[x,1] == SelectValue){
045.
var myOption = new
Option
(mySubList[x,0], mySubList[x,2])
046.
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
047.
}
048.
<%
049.
objRec.MoveNext
050.
Wend
051.
%>
052.
}
053.
//**** List Province (
End
) ***//
054.
055.
056.
//**** List Amphur (Start) ***//
057.
function ListAmphur(SelectValue)
058.
{
059.
frmMain.ddlAmphur.length = 0
060.
061.
//*** Insert null
Default
Value ***//
062.
var myOption = new
Option
(
063.
frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
064.
065.
<%
066.
strSQL =
"SELECT * FROM amphur ORDER BY AMPHUR_ID ASC "
067.
Set
objRec = Server.CreateObject(
"ADODB.Recordset"
)
068.
objRec.Open strSQL, Conn, 1,3
069.
070.
intRows = 0
071.
While
Not
objRec.EOF
072.
intRows = intRows + 1
073.
%>
074.
x = <%=intRows%>;
075.
mySubList = new Array();
076.
077.
strGroup = <%=objRec.Fields(
"PROVINCE_ID"
).Value%>;
078.
strValue =
"<%=objRec.Fields("
AMPHUR_ID
").Value%>"
;
079.
strItem =
"<%=objRec.Fields("
AMPHUR_NAME
").Value%>"
;
080.
mySubList[x,0] = strItem;
081.
mySubList[x,1] = strGroup;
082.
mySubList[x,2] = strValue;
083.
084.
if (mySubList[x,1] == SelectValue){
085.
var myOption = new
Option
(mySubList[x,0], mySubList[x,2])
086.
frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
087.
}
088.
<%
089.
objRec.MoveNext
090.
Wend
091.
%>
092.
}
093.
//**** List Amphur (
End
) ***//
094.
095.
</script>
096.
097.
098.
</head>
099.
<form name=
"frmMain"
action=
""
method=
"post"
>
100.
Geography
101.
<select id=
"ddlGeo"
name=
"ddlGeo"
onChange =
"ListProvince(this.value)"
>
102.
<option selected value=
""
></option>
103.
104.
<%
105.
strSQL =
"SELECT * FROM geography ORDER BY GEO_ID ASC "
106.
Set
objRec = Server.CreateObject(
"ADODB.Recordset"
)
107.
objRec.Open strSQL, Conn, 1,3
108.
109.
intRows = 0
110.
While
Not
objRec.EOF
111.
intRows = intRows + 1
112.
%>
113.
<option value=
"<%=objRec.Fields("
GEO_ID
").Value%>"
><%=objRec.Fields(
"GEO_NAME"
).Value%></option>
114.
<%
115.
objRec.MoveNext
116.
Wend
117.
%>
118.
</select>
119.
120.
Province
121.
<select id=
"ddlProvince"
name=
"ddlProvince"
style=
"width:120px"
onChange =
"ListAmphur(this.value)"
></select>
122.
123.
Amphur
124.
<select id=
"ddlAmphur"
name=
"ddlAmphur"
style=
"width:200px"
></select>
125.
</form>
126.
</body>
127.
</html>
128.
<%
129.
objRec.Close()
130.
Conn.Close()
131.
Set
objRec =
Nothing
132.
Set
Conn =
Nothing
133.
%>