A
Andyza
In the code from page test1.asp below I retrieve some records from a
database and create a list of classes available to users. The list
contains the names of the classes with a checkbox next to each class
so that users can select the classes that they want to attend. There
is also a drop-down list next to each class name displaying the dates
that the class will be held.
On test2.asp I retrieve the names of the classes that have been
selected (checkboxes that have been selected) using:
Request.Form("chkClassName"). No problem so far.
I also want to get the DATE that has been selected by the user for
each of the classes that he has selected. I tried retrieving this info
on test2.asp using Request.Form("lstClass") but
Request.Form("lstClass") contains the dates from ALL the drop-down
lists on test1.asp instead of just the dates from the drop-down lists
for the specific classes that the user selected.
For example, if there are 4 classes on the list and the user selects 2
classes then:
Request.Form("chkClassName") contains just the names of the 2 classes
that the user selected - which is what I want. BUT,
Request.Form("lstClass") contains the dates for ALL 4 of the classes
on the list instead of just the dates for the 2 classes that the user
selected. I only want the dates for the 2 classes that the user
selected.
Is there a way to do this?
test1.asp is:
<% @ Language=VBScript %>
<%
Dim conn, sSQL, rs1, rs2
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open Application("ConnString")
%>
<html>
<body>
<form name="frmClassSelection" method="post" action="test2.asp">
<table border="0">
<%
sSQL1 = "SELECT CourseID, CourseName FROM tblClasses ORDER BY
CourseName"
Set rs1 = conn.Execute(sSQL1)
Do While Not rs1.eof
sSQL2 = "SELECT CourseDate FROM tblClassDates WHERE CourseID =
'" & rs1("CourseID") & "' ORDER BY CourseDate"
Set rs2 = conn.Execute(sSQL2)
If rs2.eof Then
%>
<tr>
<td><input type="checkbox" name="chkClassName" value="<
%=rs1("CourseID")%>" disabled> (CourseID: <%=rs1("CourseID")%>)</td>
<td><%=rs1("CourseName")%></td>
<td>No dates available</td>
</tr>
<%
Else
%>
<tr>
<td><input type="checkbox" name="chkClassName" value="<
%=rs1("CourseID")%>"></td>
<td><%=rs1("CourseName")%></td>
<td>
<select name="lstClass">
<%
Do While Not rs2.eof
%>
<option name="optDate<%=rs1("CourseID")%>" value="<
%=rs2("CourseDate")%>"><%=rs2("CourseDate")%></option>
<%
rs2.MoveNext()
Loop
%>
</select>
</td>
</tr>
<%
End If
rs2.Close
Set rs2 = nothing
rs1.MoveNext()
Loop
rs1.Close
Set rs1 = nothing
%>
<tr>
<td colspan="3">
<input type="submit" name="btnSubmit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>
<%
conn.Close
Set conn = nothing
%>
test2.asp contains just a test page with a bunch of response.write
debug statements and a database Insert statement.
I'm using a MSSQL 2005 database and IIS and yes, I will move the sql
statements into stored procedures once I've figured out how to get the
dates from the lists!
;->
Thanks.
database and create a list of classes available to users. The list
contains the names of the classes with a checkbox next to each class
so that users can select the classes that they want to attend. There
is also a drop-down list next to each class name displaying the dates
that the class will be held.
On test2.asp I retrieve the names of the classes that have been
selected (checkboxes that have been selected) using:
Request.Form("chkClassName"). No problem so far.
I also want to get the DATE that has been selected by the user for
each of the classes that he has selected. I tried retrieving this info
on test2.asp using Request.Form("lstClass") but
Request.Form("lstClass") contains the dates from ALL the drop-down
lists on test1.asp instead of just the dates from the drop-down lists
for the specific classes that the user selected.
For example, if there are 4 classes on the list and the user selects 2
classes then:
Request.Form("chkClassName") contains just the names of the 2 classes
that the user selected - which is what I want. BUT,
Request.Form("lstClass") contains the dates for ALL 4 of the classes
on the list instead of just the dates for the 2 classes that the user
selected. I only want the dates for the 2 classes that the user
selected.
Is there a way to do this?
test1.asp is:
<% @ Language=VBScript %>
<%
Dim conn, sSQL, rs1, rs2
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open Application("ConnString")
%>
<html>
<body>
<form name="frmClassSelection" method="post" action="test2.asp">
<table border="0">
<%
sSQL1 = "SELECT CourseID, CourseName FROM tblClasses ORDER BY
CourseName"
Set rs1 = conn.Execute(sSQL1)
Do While Not rs1.eof
sSQL2 = "SELECT CourseDate FROM tblClassDates WHERE CourseID =
'" & rs1("CourseID") & "' ORDER BY CourseDate"
Set rs2 = conn.Execute(sSQL2)
If rs2.eof Then
%>
<tr>
<td><input type="checkbox" name="chkClassName" value="<
%=rs1("CourseID")%>" disabled> (CourseID: <%=rs1("CourseID")%>)</td>
<td><%=rs1("CourseName")%></td>
<td>No dates available</td>
</tr>
<%
Else
%>
<tr>
<td><input type="checkbox" name="chkClassName" value="<
%=rs1("CourseID")%>"></td>
<td><%=rs1("CourseName")%></td>
<td>
<select name="lstClass">
<%
Do While Not rs2.eof
%>
<option name="optDate<%=rs1("CourseID")%>" value="<
%=rs2("CourseDate")%>"><%=rs2("CourseDate")%></option>
<%
rs2.MoveNext()
Loop
%>
</select>
</td>
</tr>
<%
End If
rs2.Close
Set rs2 = nothing
rs1.MoveNext()
Loop
rs1.Close
Set rs1 = nothing
%>
<tr>
<td colspan="3">
<input type="submit" name="btnSubmit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>
<%
conn.Close
Set conn = nothing
%>
test2.asp contains just a test page with a bunch of response.write
debug statements and a database Insert statement.
I'm using a MSSQL 2005 database and IIS and yes, I will move the sql
statements into stored procedures once I've figured out how to get the
dates from the lists!
;->
Thanks.