Hi there I want to know how to add a drop down list based on value from a table in an asp form. Then I want the user to be able to submit the form, and the drop down list value that they have selected to be stored in a different table.
Does anyone know how to do this, I present I am using the code below, which does create the drop down list, but then I not sure how to add its value to another table in my database ( Acesss)
If anyone can help I would be very grateful!!!!
<%@ Language=VBScri pt %>
<%Option explicit
Dim oRs, conn, connect, strSQL
set conn=server.Cre ateObject ("adodb.connect ion")
connect = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & Server.MapPath( "courses.md b") & ";Persist Security Info=False"
conn.Open connect
%>
<html>
<head>
<title>Exampl e combo box</title>
<script language="javas cript">
<!--
function dept_onchange(f rmSelect) {
frmSelect.submi t();
}
//-->
</script>
</head>
<body>
The following was selected : <%=Request.Fo rm ("courses")% >
<form name="frmSelect " method="Post" action="select. asp">
<SELECT name=courses LANGUAGE=javasc ript onChange="retur n dept_onchange(f rmSelect)">
<%
Set oRs=Server.Crea teObject("adodb .recordset")
strSQL = "SELECT DISTINCT CourseName FROM tblCourses ORDER BY CourseName"
oRs.Open strSQL, conn
Do while not oRs.EOF
if Request.Form("c ourses") = oRs("CourseName ") then 'if this is the selected one then display as selected
Response.Write "<OPTION VALUE = '" & oRS ("CourseName ") & "' SELECTED>"
Response.Write oRs("CourseName ") & "</Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '" & oRs ("CourseName ") & "'>"
Response.Write oRs("CourseName ") & "</Option>"
oRs.MoveNext
end if
loop
%>
</SELECT>
</form>
</body>
</html>
Does anyone know how to do this, I present I am using the code below, which does create the drop down list, but then I not sure how to add its value to another table in my database ( Acesss)
If anyone can help I would be very grateful!!!!
<%@ Language=VBScri pt %>
<%Option explicit
Dim oRs, conn, connect, strSQL
set conn=server.Cre ateObject ("adodb.connect ion")
connect = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & Server.MapPath( "courses.md b") & ";Persist Security Info=False"
conn.Open connect
%>
<html>
<head>
<title>Exampl e combo box</title>
<script language="javas cript">
<!--
function dept_onchange(f rmSelect) {
frmSelect.submi t();
}
//-->
</script>
</head>
<body>
The following was selected : <%=Request.Fo rm ("courses")% >
<form name="frmSelect " method="Post" action="select. asp">
<SELECT name=courses LANGUAGE=javasc ript onChange="retur n dept_onchange(f rmSelect)">
<%
Set oRs=Server.Crea teObject("adodb .recordset")
strSQL = "SELECT DISTINCT CourseName FROM tblCourses ORDER BY CourseName"
oRs.Open strSQL, conn
Do while not oRs.EOF
if Request.Form("c ourses") = oRs("CourseName ") then 'if this is the selected one then display as selected
Response.Write "<OPTION VALUE = '" & oRS ("CourseName ") & "' SELECTED>"
Response.Write oRs("CourseName ") & "</Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '" & oRs ("CourseName ") & "'>"
Response.Write oRs("CourseName ") & "</Option>"
oRs.MoveNext
end if
loop
%>
</SELECT>
</form>
</body>
</html>
Comment