Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 6th, 2017, 08:39 AM
Authorized User
Points: 76, Level: 1
Points: 76, Level: 1 Points: 76, Level: 1 Points: 76, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2007
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select/Option/Value on change using Classic ASP

Hello friends,


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

Code:
         

 <%          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")                             if not 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 "end if %>><%= sName %></option>             <option value="<%= oRs("StudentID") %>" hidden></option>                                             </select>                             <%          end if             %>              <%          if request.Form("Students") <> "" then                             strSQL = " SELECT Course FROM Class WHERE StudentID = '" & request.Form("StudentID") & "'"                             Set oRs = Server.CreateObject("adodb.RecordSet")                             oRs.Open strSQL, myConn                             if not oRs.eof then %>                                             <select name="Class" id="selectClass" onChange="this.form.action='default.asp';this.form.submit();">                                                             <% do until oRs.eof  %>                                                                             <option value="<%= oRs(0) %>" <% if trim(request.Form("Class")) = trim(oRs(0)) then response.write " selected "end if %>><%= oRs(0) %></option>                                                             <% oRs.MoveNext                                                                             loop       %>                                             </select>                             <% end if                             end if             %>             <%          if request.Form("Class") <> "" then                             strSQL = " SELECT Semester FROM Class WHERE Course = '" & request.Form("Course") & "'"                             Set oRs = Server.CreateObject("adodb.RecordSet")                             oRs.Open strSQL, myConn                             if not oRs.eof then %>                                             <select name="Class" id="selectClass" onChange="this.form.action='default.asp';this.form.submit();">                                                             <% do until oRs.eof  %>                                                                             <option value="<%= oRs(0) %>" <% if trim(request.Form("Class")) = trim(oRs(0)) then response.write " selected "end if %>><%= oRs(0) %></option>                                                             <% oRs.MoveNext                                                                             loop       %>                                             </select>                             <% end if                             end if             %>

Last edited by jennypretty; June 6th, 2017 at 08:44 AM.. Reason: enter code


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I change windows password via asp classic? Vbu Classic ASP Professional 0 May 22nd, 2017 11:00 PM
change or apply theme to classic asp website mirai maria Classic ASP Professional 3 August 16th, 2015 11:22 PM
How to Change ASP.NET into Classic ASP? GailCG Classic ASP Basics 2 April 22nd, 2009 06:04 PM
Getting select option name not value mildge Javascript How-To 2 April 5th, 2004 10:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.