|
|
|
ช่วยด้วยครับ ต้องการส่งค่าจังหวัด อำเภอ ตำบล ตามไปด้วย ตามโค้ดของพี่วิน |
|
|
|
|
|
|
|
Code (ASP)
<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) ***//
//**** List District (Start) ***//
function ListDistrict(SelectValue)
{
frmMain.ddlDistrict.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlDistrict.options[frmMain.ddlDistrict.length]= myOption
<%
strSQL = "SELECT * FROM District 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("AMPHUR_ID").Value%>;
strValue = "<%=objRec.Fields("DISTRICT_ID").Value%>";
strItem = "<%=objRec.Fields("DISTRICT_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.ddlDistrict.options[frmMain.ddlDistrict.length]= myOption
}
<%
objRec.MoveNext
Wend
%>
}
//**** List Amphur (End) ***//
</script>
</head>
<body>
<form name="frmMain" action="DependentListAccept.asp" 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" onChange = "ListDistrict(this.value)"></select>
District
<select id="ddlDistrict" name="ddlDistrict" style="width:200px"></select>
Sent
<input type="submit" name="button" id="button" value="Submit">
</form>
</body>
</html>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
คือผมต้องการส่งค่าที่เป็นตัวหนังสือ จังหวัด อำเภอ ตำบล ไปยังหน้า DependentListAccept.asp ต้องแทรกโค้ดตรงไหนครับ
Tag : ASP, Ms Access
|
|
|
|
|
|
Date :
2015-02-11 10:14:50 |
By :
arta |
View :
1538 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ส่ง Code ไปก็พอครับ ที่เหลือค่อยไป Query จาก Table มาแสดงครับ
|
|
|
|
|
Date :
2015-02-11 10:48:33 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าต้องการส่งไปจริงๆ ทำได้มั้ยครับ
|
|
|
|
|
Date :
2015-02-11 11:11:20 |
By :
arta |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|