รบกวนช่วยดูโค๊ด ASP หน่อยค่ะ เลือก listbox Geography แล้วProvinceและAmphurwไม่แสดง นำ link ที่ให้พี่ช่วยดูมาแก้ไข แต่ข้อมูลมันไม่แสดงค่ะ
Code (ASP)
<%
Dim Conn,strSQL,objRec,intRows
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=192.168.0.4;Database=PDS_Training;UID=sa;PWD=trsc2004;"
strSQL = "select * from PDS_Training.dbo.lcVisitPurposeSpecificsPrice"
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>Training</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 visitpurpose,visitpurposespecific,visitprice from PDS_Training.dbo.lcVisitPurposeSpecificsPrice"
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("visitpurpose").Value%>;
strValue = "<%=objRec.Fields("visitpurposespecific").Value%>";
strItem = "<%=objRec.Fields("visitpurposespecific").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 visitpurpose,visitpurposespecific,visitprice from PDS_Training.dbo.lcVisitPurposeSpecificsPrice"
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("visitpurposespecific").Value%>;
strValue = "<%=objRec.Fields("visitprice").Value%>";
strItem = "<%=objRec.Fields("visitprice").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 distinct visitpurpose from PDS_Training.dbo.lcVisitPurposeSpecificsPrice"
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("visitpurpose").Value%>"><%=objRec.Fields("visitpurpose").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
%>
Tag : ASP, Ms SQL Server 2005, JavaScript, VBScript
Date :
2012-04-28 15:14:47
By :
nutzu9346
View :
1515
Reply :
1
มี Error หรือเปล่าครับ ลอง View Source ในหน้า IE หรือ Web Browser มาให้ดูหน่อยครับ
Date :
2012-04-28 22:49:36
By :
webmaster
Load balance : Server 01