I am going to do the best I can describing the trouble I am having.
I inherited a shopping cart type application that allows users to sign up for courses online. I did not write this application, but now I need to add enhancements to it.
If a user registers for a quantity of more than one for a given course, the number of text boxes to be displayed will equal the quantity chosen... if they register for a quantity of one, there will be no text box. So if I register for a quantity of one, there will be no text boxes. If I register for a quantity of three, there will be three text boxes. In these text boxes, the user will enter the email addresses of the other people they would like to register for a given course.
So here's my problem. When I submit this request for processing, how do I grab the email addresses entered into those textboxes (if there are any textboxes at all)? I am not sure how to name them, or loop through them to get their values. I want to grab those email address (if there are any) and do an insert into the database, along with the course number and session id. And I am further confused by the fact that there can be more than one course in the shopping cart...
Here's an excerpt from the code I have so far. I have tried multiple ways to get this to work, to no avail.
I inherited a shopping cart type application that allows users to sign up for courses online. I did not write this application, but now I need to add enhancements to it.
If a user registers for a quantity of more than one for a given course, the number of text boxes to be displayed will equal the quantity chosen... if they register for a quantity of one, there will be no text box. So if I register for a quantity of one, there will be no text boxes. If I register for a quantity of three, there will be three text boxes. In these text boxes, the user will enter the email addresses of the other people they would like to register for a given course.
So here's my problem. When I submit this request for processing, how do I grab the email addresses entered into those textboxes (if there are any textboxes at all)? I am not sure how to name them, or loop through them to get their values. I want to grab those email address (if there are any) and do an insert into the database, along with the course number and session id. And I am further confused by the fact that there can be more than one course in the shopping cart...
Here's an excerpt from the code I have so far. I have tried multiple ways to get this to work, to no avail.
Code:
Sub ShowCart
Response.Write"<TABLE Border='0' CellPadding='3' CellSpacing='0' width='100%'>" & _
"<TR><TD> </TD><TD>" & _
"<TABLE Border='0' CellPadding='3' CellSpacing='0' width='100%'>" & _
"<TR><TD class='txtB14Blue' colspan='3'>Verify Your Order</td></TR>" & _
"<TR><TD class='txtB10' width='7%' valign='bottom' align='center'>Quantity</td>" & _
"<TD class='txtB10' width='63%' valign='bottom' align='center'>Description</TD>"
IF bMember = False Then
Response.Write "<TD class='txtB10' width='15%' valign='bottom' align='right'>Non-Member Price</TD></TR>"
Else
Response.Write "<TD class=txtB10 width='15%' valign='bottom' align='right'>Member Price</TD></TR>"
End If
Response.Write "<tr><td colspan='3' align='center'><hr color='#000099' width='100%'></td></tr>"
fTotalM = 0
fTotalNonM = 0
iCount = 0
sSQL = "SELECT Member_Fee, Non_Member_Fee, Shop.Description Descript, Title, Shop.Quantity, CAST(Event AS Int) As EvNo " & _
" FROM RP_Event, Orders_ShopCart As Shop WHERE RP_Event.RP_Event_Id=Shop.Event AND Shop.SessionID=" & Session.SessionID
Set RS = ConnectED.Execute(sSQL)
DO While Not RS.Eof
iCount = iCount + 1
IF iCount MOD 2 = 0 THEN
Response.Write "<TR bgcolor='#E8ECF9'>" & _
"<TD class='txt10' align='center' valign='top'>"
IF RS("Quantity") = 1 Then
Response.Write RS("Quantity") &"</td>" & _
"<TD class='txt10'>" & RS("Descript") & ", " & RS("Title") & "<br></TD>"
IF bMember = False Then
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Non_Member_Fee"), 2) & "</TD></TR>"
ELSE
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Member_Fee"), 2) & "</TD></TR>"
END IF
ELSE
Response.Write RS("Quantity") &"</td>" & _
"<TD class='txt10'>" & RS("Descript") & ", " & RS("Title") & "<br></TD>"
IF bMember = False Then
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Non_Member_Fee"), 2) & "</TD></TR>"
ELSE
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Member_Fee"), 2) & "</TD></TR>"
END IF
Response.write "<tr bgcolor='#E8ECF9'><td> </td><td class='txt8Blue'><i>You ordered a quantity of more than one for the same course. Please enter the email address(es) of the additional registrant(s).</i></td><td> </td></tr>"
Dim qtyCnt
qtyCnt = 0
Do Until qtyCnt = RS("Quantity")
qtyCnt = qtyCnt + 1
Response.Write "<tr bgcolor='#E8ECF9'><td> </td><td class='txt8Blue'>Registrant #" & qtyCnt & ": <input type='text' name='txtAddReg" & EvNo & "[" & qtyCnt & "]' width='25' value=''></td><td> </td></tr>"
Loop
END IF
ELSE
Response.Write "<TR bgcolor='#ffffff'>" & _
"<TD class='txt10' align='center' valign='top'>"
IF RS("Quantity") = 1 Then
Response.Write RS("Quantity") &"</td>" & _
"<TD class='txt10'>" & RS("Descript") & ", " & RS("Title") & "<br></TD>"
IF bMember = False Then
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Non_Member_Fee"), 2) & "</TD></TR>"
ELSE
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Member_Fee"), 2) & "</TD></TR>"
END IF
ELSE
Response.Write RS("Quantity") &"</td>" & _
"<TD class='txt10'>" & RS("Descript") & ", " & RS("Title") & "<br></TD>"
IF bMember = False Then
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Non_Member_Fee"), 2) & "</TD></TR>"
ELSE
Response.Write "<TD class='txt10' align='right' valign='top'>$ " & FormatNumber(RS("Quantity") * RS("Member_Fee"), 2) & "</TD></TR>"
END IF
Response.write "<tr bgcolor='#ffffff'><td> </td><td class='txt8Blue'><i>You ordered a quantity of more than one for the same course. Please enter the email address(es) of the additional registrant(s).</i></td><td> </td></tr>"
Dim qntyCnt
qntyCnt = 0
Do Until qntyCnt = RS("Quantity")
qntyCnt = qntyCnt + 1
Response.Write "<tr bgcolor='#ffffff'><td> </td><td class='txt8Blue'>Registrant #" & qtyCnt & ": <input type='text' name='txtAddReg" & EvNo & "[" & qtyCnt & "]' width='25' value=''></td><td> </td></tr>"
Loop
END IF
END IF
fTotalM = fTotalM + (RS("Quantity") * RS("Member_Fee"))
fTotalNonM = fTotalNonM + (RS("Quantity") * RS("Non_Member_Fee"))
RS.MoveNext
Loop
If iCount > 0 Then
Response.Write "<TR><TD ALIGN='Right' colspan='2' class='txtB10' valign='bottom'><br><br>Total: </TD>"
IF bMember = False Then
Response.Write "<TD ALIGN='right' class='txtB10' valign='bottom'>$ " & FormatNumber(fTotalNonM,2) & "</TD></TR>"
ELSE
Response.Write "<TD ALIGN='right' class='txtB10' valign='bottom'>$ " & FormatNumber(fTotalM,2) & "</TD></TR>"
END IF
Response.Write "<tr><td colspan='3' align='right'><br><br><a href='EmailOrder.asp'>Email Order to Customer Service <img src='images/Icon_GoldArrow.gif' border ='0'></a> <a href='" & sSecureSite & "AskInfo.asp'>Place Order Now Using Credit Card <img src='images/Icon_GoldArrow.gif' border='0'></a></td></tr></table>"
Else
Response.Write "<TR><TD ALIGN='center' colspan='3' class='txtB10'>No Items on your Order</TD></TR></TABLE>"
End If
End Sub