<div> <div class="post-text" itemprop="text"> I tried to create a select option value on change using classic ASP but it didn't work. No error but when I view, nothing pop up from second select. I like to select student name from first select box, if it matches, then second box shows course name, and third box shows Semester. I like to store student names and StudentID into DB. Can anyone help? Students table StudentID Firstname Lastname ------------------------------- 01 AAA LN1 02 BBB LN2 03 CCC LN3 Class table Course CourseID StudentID Semester------------------------------------- History C01 01 Spring History C01 01 Summer Math C02 02 Spring Math C02 02 Fall </div></div><%Set oRs = Server.CreateObject("adodb.recordset") strSQL =" SELECT StudentID, Firstname, Lastname FROM Students Where StudentID = '"& Request.ServerVariables("LOGON_Student")&"'" oRs.Open strSQL, myConn sName = oRs("Lastname")&", "& oRs("Firstname")ifnot oRs.eof then%><select name="Students" id="selectStudent" onChange="this.form.action='default.asp';this.form.submit();"><option value="<%= oRs(0) %>"<%if trim(request.Form("Students"))= trim(oRs(0))then response.write " selected "endif%>><%= sName %></option><option value="<%= oRs("StudentID") %>" hidden></option></select><%endif%><%if request.Form("Students")<>""then strSQL =" SELECT Course FROM Class WHERE StudentID = '"& request.Form("StudentID")&"'"Set oRs = Server.CreateObject("adodb.RecordSet") oRs.Open strSQL, myConnifnot oRs.eof then%><select name="Class" id="selectClass" onChange="this.form.action='default.asp';this.form.submit();"><%dountil oRs.eof %><option value="<%= oRs(0) %>"<%if trim(request.Form("Class"))= trim(oRs(0))then response.write " selected "endif%>><%= oRs(0)%></option><% oRs.MoveNextloop%></select><%endifendif%><%if request.Form("Class")<>""then strSQL =" SELECT Semester FROM Class WHERE Course = '"& request.Form("Course")&"'"Set oRs = Server.CreateObject("adodb.RecordSet") oRs.Open strSQL, myConnifnot oRs.eof then%><select name="Class" id="selectClass" onChange="this.form.action='default.asp';this.form.submit();"><%dountil oRs.eof %><option value="<%= oRs(0) %>"<%if trim(request.Form("Class"))= trim(oRs(0))then response.write " selected "endif%>><%= oRs(0)%></option><% oRs.MoveNextloop%></select><%endifendif%> |
↧
Select/Option/Value on change using Classic ASP
↧