sql="select * from asia inner join county on asia.county=county.id_county inner join province on asia.Province=province.id_province inner join sector on asia.zone=sector.sector_id order by asia.id desc"
แต่ถ้าทำเหมือนเว็บ http://www.asiainsurance.co.th/garage_new/garageG.aspx นี้ไม่รู้ต้องเริ่ม โค๊ตยังงัยค่ะพี่พี่ช่วยแนะนำโค๊ตค้นหาด้วยค่ะ ขอบคุณค่ะ
Code (ASP)
<%
'*** By Weerachai Nukitram ***'
'*** http://www.ThaiCreate.Com ***'
Option Explicit
Dim Conn,strSQL,objRec,intRows
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("db/thailand.mdb"),"" , ""
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>ThaiCreate.Com ListMenu</title>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
frmMain.ddlProvince.length = 0
frmMain.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
<%
strSQL = "SELECT * FROM province ORDER BY PROVINCE_ID ASC "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
intRows = 0
While Not objRec.EOF
intRows = intRows + 1
%>
x = <%=intRows%>;
mySubList = new Array();
strGroup = <%=objRec.Fields("GEO_ID").Value%>;
strValue = "<%=objRec.Fields("PROVINCE_ID").Value%>";
strItem = "<%=objRec.Fields("PROVINCE_NAME").Value%>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
}
<%
objRec.MoveNext
Wend
%>
}
//**** List Province (End) ***//
//**** List Amphur (Start) ***//
function ListAmphur(SelectValue)
{
frmMain.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
<%
strSQL = "SELECT * FROM amphur ORDER BY AMPHUR_ID ASC "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
intRows = 0
While Not objRec.EOF
intRows = intRows + 1
%>
x = <%=intRows%>;
mySubList = new Array();
strGroup = <%=objRec.Fields("PROVINCE_ID").Value%>;
strValue = "<%=objRec.Fields("AMPHUR_ID").Value%>";
strItem = "<%=objRec.Fields("AMPHUR_NAME").Value%>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
}
<%
objRec.MoveNext
Wend
%>
}
//**** List Amphur (End) ***//
</script>
</head>
<form name="frmMain" action="" method="post">
Geography
<select id="ddlGeo" name="ddlGeo" onChange = "ListProvince(this.value)">
<option selected value=""></option>
<%
strSQL = "SELECT * FROM geography ORDER BY GEO_ID ASC "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
intRows = 0
While Not objRec.EOF
intRows = intRows + 1
%>
<option value="<%=objRec.Fields("GEO_ID").Value%>"><%=objRec.Fields("GEO_NAME").Value%></option>
<%
objRec.MoveNext
Wend
%>
</select>
Province
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "ListAmphur(this.value)"></select>
Amphur
<select id="ddlAmphur" name="ddlAmphur" style="width:200px"></select>
</form>
</body>
</html>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>