dynamic dropdown boxes
hello,
the logic behind the code i post is as follows:
the user selects a studentid from the dropdown box and the second dropdown box automatically displays the corresponding student name.
i need to post the data in the dropdown boxes to another database. i am ok with that just that there's a wrong posting taking place.
the code posts the same drop down value to two fields - studentid field gets the studentid value and the studentname field also gets the studentid value. if you look well in the code you will see why it is doing that. i have not yet managed to find a solution to this probelm and so i am asking for help.
<%
Dim conn
Dim rs
Dim strconn
Session("DataConn_ConnectionString") = _
"DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath("\db.mdb")
strconn = Session("DataConn_ConnectionString")
set conn = server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")
conn.open strconn
strsql = "SELECT StudentId, StudentName FROM students"
rs.open strsql, conn, 2, 2
Response.Write "<SELECT name=studentid onchange=""studentname.value = this.value;"">"
While not rs.EOF
Response.Write "<OPTION value=" & rs("studentid") & ">" & rs("studentid") & "</OPTION>"
rs.MoveNext
Wend
Response.Write "</SELECT>"
rs.MoveFirst
Response.Write "<SELECT name=studentname onchange=""studentid.value = this.value;"">"
While not rs.EOF
Response.Write "<OPTION value=" & rs("studentid") & ">" & rs("studentname") & "</OPTION>"
rs.MoveNext
Wend
Response.Write "</SELECT>"
%>
is there a way whereby i could solve this problem? studentid dropdown box posts to studentid field and studentname posts to studentname field.
i would appreciate your help.
fmh002
|