Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 01:57 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.