|
|
|
ASP : menu drop ไม่จัดเก็บครับ page_add |
|
|
|
|
|
|
|
menu drop ไม่จัดเก็บครับ
page_add
Code (ASP)
<%
Dim Conn,strSQL,objRec,strDefault,strSel,strSQL2,objRec2,intRows2
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../../../enroll/web/Province_test.mdb"),"" , ""
%>
<html>
<head>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
frmAdd.ddlProvince.length = 0
frmAdd.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmAdd.ddlProvince.options[frmAdd.ddlProvince.length]= myOption
<%
strSQL2 = "SELECT * FROM province2018 ORDER BY PROVINCE_ID ASC "
Set objRec2 = Server.CreateObject("ADODB.Recordset")
objRec2.Open strSQL2, Conn, 1,3
intRows2 = 0
While Not objRec2.EOF
intRows2 = intRows2 + 1
%>
x = <%=intRows2%>;
mySubList = new Array();
strGroup = <%=objRec2.Fields("GEO_ID").Value%>;
strValue = "<%=objRec2.Fields("PROVINCE_ID").Value%>";
strItem = "<%=objRec2.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])
frmAdd.ddlProvince.options[frmAdd.ddlProvince.length]= myOption
}
<%
objRec2.MoveNext
Wend
%>
}
//**** List Province (End) ***//
//**** List Amphur (Start) ***//
function ListAmphur(SelectValue)
{
frmAdd.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmAdd.ddlAmphur.options[frmAdd.ddlAmphur.length]= myOption
<%
strSQL2 = "SELECT * FROM amphur2018 ORDER BY AMPHUR_ID ASC "
Set objRec2 = Server.CreateObject("ADODB.Recordset")
objRec2.Open strSQL2, Conn, 1,3
intRows2 = 0
While Not objRec2.EOF
intRows2 = intRows2 + 1
%>
x = <%=intRows2%>;
mySubList = new Array();
strGroup = <%=objRec2.Fields("PROVINCE_ID").Value%>;
strValue = "<%=objRec2.Fields("AMPHUR_ID").Value%>";
strItem = "<%=objRec2.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])
frmAdd.ddlAmphur.options[frmAdd.ddlAmphur.length]= myOption
}
<%
objRec2.MoveNext
Wend
%>
}
//**** List Amphur (End) ***//
</script>
</head>
<body>
<!--#include file="bar.asp"-->
<form action="AspAccessAddSave.asp" name="frmAdd" method="post">
<table width="600" border="1">
<tr>
<th width="100%"> <div align="center">Code </div></th>
<th width="100%"> <div align="center">SchoolName </div></th>
<th width="100%"> <div align="center">Area </div></th>
<th width="200"> <div align="center">Zone </div></th>
<th width="198"> <div align="center">Amphur </div></th>
<th width="70"> <div align="center">CourseStatus </div></th>
<th width="70"> <div align="center">RegStatus </div></th>
</tr>
<tr>
<td><div align="center">
<input type="text" name="txtCode" size="20">
</div></td>
<td><input type="text" name="txtSchoolName" size="20"></td>
<td>
<select id="ddlGeo" name="ddlGeo" onChange = "ListProvince(this.value)">
<option selected value=""></option>
<%
strSQL2 = "SELECT * FROM geography2018 ORDER BY GEO_ID ASC "
Set objRec2 = Server.CreateObject("ADODB.Recordset")
objRec2.Open strSQL2, Conn, 1,3
intRows2 = 0
While Not objRec2.EOF
intRows2 = intRows2 + 1
%>
<option value="<%=objRec2.Fields("GEO_ID").Value%>"><%=objRec2.Fields("GEO_NAME").Value%></option>
<%
objRec2.MoveNext
Wend
%>
</select>
</td>
<td>
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "ListAmphur(this.value)">
</select> </td>
<td>
<select id="ddlAmphur" name="ddlAmphur" style="width:200px">
</select></td>
<td > <select name="txtCourseStatus">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select></td>
<td ><input type="text" name="txtRegStatus" size="20" value="1" readonly></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<%
objRec2.Close()
Conn.Close()
Set objRec2 = Nothing
Set Conn = Nothing
%>
AspAccessAddSave
Code (ASP)
<% Option Explicit %>
<html>
<head>
</head>
<!--#include file="bar.asp"-->
<body>
<%
Dim Conn,strSQL,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../../../enroll/web/Province_test.mdb"),"" , ""
strSQL = ""
strSQL = strSQL &"INSERT INTO School "
strSQL = strSQL &"(Code,SchoolName,Amphur,Zone,CourseStatus,RegStatus) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &"('"&Request.Form("txtCode")&"','"&Request.Form("txtSchoolName")&"','"&Request.Form("txtAmphur")&"' "
strSQL = strSQL &",'"&Request.Form("txtZone")&"','"&Request.Form("txtCourseStatus")&"','"&Request.Form("txtRegStatus")&"') "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End If
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
</body>
</html>
Tag : ASP, Ms Access
|
|
|
|
|
|
Date :
2018-03-23 17:04:24 |
By :
shiowa |
View :
1483 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (ASP)
Response.write strSQL
Set objExec = Conn.Execute(strSQL)
ดูค่าว่าส่งมาหรือไม่ครับ
|
|
|
|
|
Date :
2018-03-23 21:39:36 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 1 เขียนโดย : mr.win เมื่อวันที่ 2018-03-23 21:39:36
รายละเอียดของการตอบ ::
ตอนนี้ได้แล้ว แต่ติด ตรงนี้ครับ อำเภอไม่มา เพราะผมไปเปลี่ยน strValue = "<%=objRec2.Fields("PROVINCE_NAME").Value%>";
(PROVINCE_ID-->PROVINCE_NAME) บรรทัดที่ 38
Code (ASP)
<%
Dim Conn,strSQL,objRec,strDefault,strSel,strSQL2,objRec2,intRows2
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../../../enroll/web/Province_test.mdb"),"" , ""
%>
<html>
<head>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
frmAdd.ddlProvince.length = 0
frmAdd.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmAdd.ddlProvince.options[frmAdd.ddlProvince.length]= myOption
<%
strSQL2 = "SELECT * FROM province2018 ORDER BY PROVINCE_ID ASC "
Set objRec2 = Server.CreateObject("ADODB.Recordset")
objRec2.Open strSQL2, Conn, 1,3
intRows2 = 0
While Not objRec2.EOF
intRows2 = intRows2 + 1
%>
x = <%=intRows2%>;
mySubList = new Array();
strGroup = <%=objRec2.Fields("GEO_ID").Value%>;
strValue = "<%=objRec2.Fields("PROVINCE_NAME").Value%>";
strItem = "<%=objRec2.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])
frmAdd.ddlProvince.options[frmAdd.ddlProvince.length]= myOption
}
<%
objRec2.MoveNext
Wend
%>
}
//**** List Province (End) ***//
//**** List Amphur (Start) ***//
function ListAmphur(SelectValue)
{
frmAdd.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmAdd.ddlAmphur.options[frmAdd.ddlAmphur.length]= myOption
<%
strSQL2 = "SELECT * FROM amphur2018 ORDER BY AMPHUR_ID ASC "
Set objRec2 = Server.CreateObject("ADODB.Recordset")
objRec2.Open strSQL2, Conn, 1,3
intRows2 = 0
While Not objRec2.EOF
intRows2 = intRows2 + 1
%>
x = <%=intRows2%>;
mySubList = new Array();
strGroup = <%=objRec2.Fields("PROVINCE_ID").Value%>;
strValue = "<%=objRec2.Fields("AMPHUR_ID").Value%>";
strItem = "<%=objRec2.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])
frmAdd.ddlAmphur.options[frmAdd.ddlAmphur.length]= myOption
}
<%
objRec2.MoveNext
Wend
%>
}
//**** List Amphur (End) ***//
</script>
</head>
<body>
<!--#include file="bar.asp"-->
<form action="AspAccessAddSave.asp" name="frmAdd" method="post">
<table width="600" border="1">
<tr>
<th width="100%"> <div align="center">Code </div></th>
<th width="100%"> <div align="center">SchoolName </div></th>
<th width="100%"> <div align="center">Area </div></th>
<th width="200"> <div align="center">Zone </div></th>
<th width="198"> <div align="center">Amphur </div></th>
<th width="70"> <div align="center">CourseStatus </div></th>
<th width="70"> <div align="center">RegStatus </div></th>
</tr>
<tr>
<td><div align="center">
<input type="text" name="txtCode" size="20">
</div></td>
<td><input type="text" name="txtSchoolName" size="20"></td>
<td>
<select id="ddlGeo" name="ddlGeo" onChange = "ListProvince(this.value)">
<option selected value=""></option>
<%
strSQL2 = "SELECT * FROM geography2018 ORDER BY GEO_ID ASC "
Set objRec2 = Server.CreateObject("ADODB.Recordset")
objRec2.Open strSQL2, Conn, 1,3
intRows2 = 0
While Not objRec2.EOF
intRows2 = intRows2 + 1
%>
<option value="<%=objRec2.Fields("GEO_ID").Value%>"><%=objRec2.Fields("GEO_NAME").Value%></option>
<%
objRec2.MoveNext
Wend
%>
</select>
</td>
<td>
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "ListAmphur(this.value)">
</select> </td>
<td>
<select id="ddlAmphur" name="ddlAmphur" style="width:200px">
</select></td>
<td > <select name="txtCourseStatus">
<option value="0">0</option>
<option value="1">1</option>
</select></td>
<td ><input type="text" name="txtRegStatus" size="20" value="1" readonly></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<%
objRec2.Close()
Conn.Close()
Set objRec2 = Nothing
Set Conn = Nothing
%>
|
ประวัติการแก้ไข 2018-03-24 09:11:15 2018-03-24 09:14:38
|
|
|
|
Date :
2018-03-24 09:10:27 |
By :
ffff |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|