|
 |
asp_components thread: STUDENT NEEDS HELP PLEASE................................
Message #1 by "DAVID GOBLE" <DavidRGJR@h...> on Tue, 2 Apr 2002 21:45:34
|
|
http://p2p.wrox.com/post.asp?list=access_asp
Okay everybody, I hope someone can help (BECAUSE MY TEACHER CAN'T)
If you want to show your knowledge to a complete stranger and have him bow
down to you please help me find a solution to this problem.
I have two pages (all code shown below) that displays a list of products a
user can select to have added to their 'shopping cart'. The problem is,
how do you tell the second page to retrieve the values that the user has
selected.
I try to use the Request.Form() function but it tells me that the variable
must have "" inorder to be retrieved.
I know that this is difficult to ask over the web but at this point i am
despirate and no one at my college can help me.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>
<form method="POST" action="emp_verifyproddistributors.asp">
<body>
<u><b><font size="4"><font color="#02089E">Distributor
Products</font></u><br>
</font></b>
<table border=0>
<tr>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Selection</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Distributor</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>City</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>State</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Zip</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2>If 'Add'ed,<br>Dist. Product #</font></td>
</tr>
<%
'Declare variables
Dim objconn
Dim strconn
Dim rsDistributor
Dim sqlstmt
Dim varA
Dim varB
Dim numVariable
numVariable = 0
'Set up connection.
set objconn = Server.CreateObject("ADODB.Connection")
strconn = "File Name=" + Server.MapPath("access.udl")
objconn.Open strconn
'Set up new recordset and get information from database.
set rsDistributor= Server.CreateObject("ADODB.Recordset")
rsDistributor.CursorType = adOpenDynamic
sqlstmt = "SELECT * FROM distributor_information"
rsDistributor.Open sqlstmt, objconn
'Display all products for the user to select the correct products.
If Not rsDistributor.EOF Then
Do While Not rsDistributor.EOF
numVariable = numVariable + 1
Response.Write "<font size = 2><tr>"
Response.Write "<td align = ""center"">"
Response.Write "<select name = """
Response.Write numVariable
Response.Write """>"
Response.Write "<option selected = ""selected""
value = ""0"">Not Selected</option>"
Response.Write "<option value = """
Response.Write Trim(rsDistributor
("d_distributor_number"))
Response.Write """>Add</option></td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor
("d_company_name"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_city"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_state"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_zip"))
Response.Write "</td>"
Response.Write "<td><center><input type=""text""
id=""txt"
Response.Write numVariable
Response.Write """ size = ""10"" max length
= ""50"" /></td>"
Response.Write "</tr></font></center>"
rsDistributor.MoveNext
Loop
Else
Response.Write "<tr><td align=""center""
colspan=""7"">ERROR: There are no distributors currently
available</td></tr>"
End If
varA = numVariable
varB = CStr(varA)
Session("numTotalNumDistributors") = ""
Session("numTotalNumDistributors") = varB
rsDistributor.close
objconn.close
%>
<tr>
<td align="center" colspan="7"><br>
<input type="Submit" value="Update Product Info">
<input type="reset"></td>
</tr>
</table>
</body>
</form>
</html>
PAGE 2
<%
'Declare variables
Dim objconn
Dim strconn
Dim rsSelection
Dim sqlstmt
Dim varA
Dim varB
Dim numTotalRemaining
Dim numTotalSelected
varA = Session("numTotalNumDistributors")
varB = CLng(varA)
numTotalRemaining = varB
'Set up connection.
set objconn = Server.CreateObject("ADODB.Connection")
strconn = "File Name=" + Server.MapPath("access.udl")
objconn.Open strconn
'Set up new recordset and get information from database.
set rsSelection = Server.CreateObject("ADODB.Recordset")
rsSelection.CursorType = adOpenDynamic
rsSelection.LockType = adLockOptimistic
sqlstmt = "SELECT * FROM distributor_product_line"
rsSelection.Open sqlstmt, objconn
'Perform until numVariable is equal to zero.
Do While numTotalRemaining <> 0
'If the customer has selected that product then write a
new record.
If Request.Form(numTotalRemaining) <> "0" Then ?<- HERE
IS THE PROBLEM
varA = Request.Form(numTotalRemaining) ?<- HERE
IS THE PROBLEM
varB = varB
rsSelection.AddNew
rsSelection("dpl_distributor_number") = varB
varA = Session("strNewProductNumber")
varB = varA
rsSelection("dpl_product_number") = varB
rsSelection("dpl_date_created") = Date
varA = Chr(numTotalRemaining) ?<- HERE
IS THE PROBLEM
varB = "txt"
varB = varB + varA
rsSelection("dpl_distributor_product_number") =
Request.Form("txt" + varB) ?<- HERE IS THE PROBLEM
rsSelection.Update
numTotalRemaining = numTotalRemaining - 1
Else
numTotalRemaining = numTotalRemaining - 1
End If
Loop
Session("strCompInfo") = ""
Session("strCompInfo") = "Information Updated"
Response.Redirect("emp_new_completion.asp")
rsSelection.close
objconn.close
%>
PLEASE HELP
Message #2 by "Bernard Williams" <bernardwilliams@j...> on Tue, 2 Apr 2002 14:40:28 -0600
|
|
You can use the session variable to store everything in an then retrieve
them later.
For Each strField in rsUsers.Fields
strName = strField.Name
strValue = strField.value
Session(strName) = strValue
Next
-----Original Message-----
From: DAVID GOBLE [mailto:DavidRGJR@h...]
Sent: Tuesday, April 02, 2002 9:46 PM
To: ASP components
Subject: [asp_components] STUDENT NEEDS HELP
PLEASE................................
http://p2p.wrox.com/post.asp?list=access_asp
Okay everybody, I hope someone can help (BECAUSE MY TEACHER CAN'T)
If you want to show your knowledge to a complete stranger and have him
bow
down to you please help me find a solution to this problem.
I have two pages (all code shown below) that displays a list of products
a
user can select to have added to their 'shopping cart'. The problem is,
how do you tell the second page to retrieve the values that the user has
selected.
I try to use the Request.Form() function but it tells me that the
variable
must have "" inorder to be retrieved.
I know that this is difficult to ask over the web but at this point i am
despirate and no one at my college can help me.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title></title>
</head>
<form method="POST" action="emp_verifyproddistributors.asp">
<body>
<u><b><font size="4"><font color="#02089E">Distributor
Products</font></u><br>
</font></b>
<table border=0>
<tr>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Selection</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Distributor</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>City</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>State</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Zip</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2>If 'Add'ed,<br>Dist. Product #</font></td>
</tr>
<%
'Declare variables
Dim objconn
Dim strconn
Dim rsDistributor
Dim sqlstmt
Dim varA
Dim varB
Dim numVariable
numVariable = 0
'Set up connection.
set objconn = Server.CreateObject("ADODB.Connection")
strconn = "File Name=" + Server.MapPath("access.udl")
objconn.Open strconn
'Set up new recordset and get information from database.
set rsDistributor= Server.CreateObject("ADODB.Recordset")
rsDistributor.CursorType = adOpenDynamic
sqlstmt = "SELECT * FROM distributor_information"
rsDistributor.Open sqlstmt, objconn
'Display all products for the user to select the correct
products.
If Not rsDistributor.EOF Then
Do While Not rsDistributor.EOF
numVariable = numVariable + 1
Response.Write "<font size = 2><tr>"
Response.Write "<td align = ""center"">"
Response.Write "<select name = """
Response.Write numVariable
Response.Write """>"
Response.Write "<option selected = ""selected""
value = ""0"">Not Selected</option>"
Response.Write "<option value = """
Response.Write Trim(rsDistributor
("d_distributor_number"))
Response.Write """>Add</option></td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor
("d_company_name"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_city"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_state"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_zip"))
Response.Write "</td>"
Response.Write "<td><center><input type=""text""
id=""txt"
Response.Write numVariable
Response.Write """ size = ""10"" max length
= ""50"" /></td>"
Response.Write "</tr></font></center>"
rsDistributor.MoveNext
Loop
Else
Response.Write "<tr><td align=""center""
colspan=""7"">ERROR: There are no distributors currently
available</td></tr>"
End If
varA = numVariable
varB = CStr(varA)
Session("numTotalNumDistributors") = ""
Session("numTotalNumDistributors") = varB
rsDistributor.close
objconn.close
%>
<tr>
<td align="center" colspan="7"><br>
<input type="Submit" value="Update Product
Info">
<input type="reset"></td>
</tr>
</table>
</body>
</form>
</html>
PAGE 2
<%
'Declare variables
Dim objconn
Dim strconn
Dim rsSelection
Dim sqlstmt
Dim varA
Dim varB
Dim numTotalRemaining
Dim numTotalSelected
varA = Session("numTotalNumDistributors")
varB = CLng(varA)
numTotalRemaining = varB
'Set up connection.
set objconn = Server.CreateObject("ADODB.Connection")
strconn = "File Name=" + Server.MapPath("access.udl")
objconn.Open strconn
'Set up new recordset and get information from database.
set rsSelection = Server.CreateObject("ADODB.Recordset")
rsSelection.CursorType = adOpenDynamic
rsSelection.LockType = adLockOptimistic
sqlstmt = "SELECT * FROM distributor_product_line"
rsSelection.Open sqlstmt, objconn
'Perform until numVariable is equal to zero.
Do While numTotalRemaining <> 0
'If the customer has selected that product then write a
new record.
If Request.Form(numTotalRemaining) <> "0" Then '<-
HERE
IS THE PROBLEM
varA = Request.Form(numTotalRemaining) '<- HERE
IS THE PROBLEM
varB = varB
rsSelection.AddNew
rsSelection("dpl_distributor_number") = varB
varA = Session("strNewProductNumber")
varB = varA
rsSelection("dpl_product_number") = varB
rsSelection("dpl_date_created") = Date
varA = Chr(numTotalRemaining) '<- HERE
IS THE PROBLEM
varB = "txt"
varB = varB + varA
rsSelection("dpl_distributor_product_number") =
Request.Form("txt" + varB) '<- HERE IS THE PROBLEM
rsSelection.Update
numTotalRemaining = numTotalRemaining - 1
Else
numTotalRemaining = numTotalRemaining - 1
End If
Loop
Session("strCompInfo") = ""
Session("strCompInfo") = "Information Updated"
Response.Redirect("emp_new_completion.asp")
rsSelection.close
objconn.close
%>
PLEASE HELP
bernardwilliams@j...
%%email.unsub%%
Message #3 by Shaun Steckley <SSTECKLEY@P...> on Tue, 2 Apr 2002 15:44:22 -0500
|
|
I do not know if this is the problem, but I noticed this when looking over
your code really quick...
Request.Form("txt" + varB)
Should be:
Request.Form("txt" & varB)
-----Original Message-----
From: DAVID GOBLE [mailto:DavidRGJR@h...]
Sent: Tuesday, April 02, 2002 4:46 PM
To: ASP components
Subject: [asp_components] STUDENT NEEDS HELP
PLEASE................................
http://p2p.wrox.com/post.asp?list=access_asp
Okay everybody, I hope someone can help (BECAUSE MY TEACHER CAN'T)
If you want to show your knowledge to a complete stranger and have him bow
down to you please help me find a solution to this problem.
I have two pages (all code shown below) that displays a list of products a
user can select to have added to their 'shopping cart'. The problem is,
how do you tell the second page to retrieve the values that the user has
selected.
I try to use the Request.Form() function but it tells me that the variable
must have "" inorder to be retrieved.
I know that this is difficult to ask over the web but at this point i am
despirate and no one at my college can help me.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>
<form method="POST" action="emp_verifyproddistributors.asp">
<body>
<u><b><font size="4"><font color="#02089E">Distributor
Products</font></u><br>
</font></b>
<table border=0>
<tr>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Selection</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Distributor</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>City</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>State</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2><br>Zip</font></td>
<td align="center"><font color="#02089E" face="Courier
New" size = 2>If 'Add'ed,<br>Dist. Product #</font></td>
</tr>
<%
'Declare variables
Dim objconn
Dim strconn
Dim rsDistributor
Dim sqlstmt
Dim varA
Dim varB
Dim numVariable
numVariable = 0
'Set up connection.
set objconn = Server.CreateObject("ADODB.Connection")
strconn = "File Name=" + Server.MapPath("access.udl")
objconn.Open strconn
'Set up new recordset and get information from database.
set rsDistributor= Server.CreateObject("ADODB.Recordset")
rsDistributor.CursorType = adOpenDynamic
sqlstmt = "SELECT * FROM distributor_information"
rsDistributor.Open sqlstmt, objconn
'Display all products for the user to select the correct products.
If Not rsDistributor.EOF Then
Do While Not rsDistributor.EOF
numVariable = numVariable + 1
Response.Write "<font size = 2><tr>"
Response.Write "<td align = ""center"">"
Response.Write "<select name = """
Response.Write numVariable
Response.Write """>"
Response.Write "<option selected = ""selected""
value = ""0"">Not Selected</option>"
Response.Write "<option value = """
Response.Write Trim(rsDistributor
("d_distributor_number"))
Response.Write """>Add</option></td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor
("d_company_name"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_city"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_state"))
Response.Write "</td>"
Response.Write "<td align = ""center"">"
Response.Write Trim(rsDistributor("d_zip"))
Response.Write "</td>"
Response.Write "<td><center><input type=""text""
id=""txt"
Response.Write numVariable
Response.Write """ size = ""10"" max length
= ""50"" /></td>"
Response.Write "</tr></font></center>"
rsDistributor.MoveNext
Loop
Else
Response.Write "<tr><td align=""center""
colspan=""7"">ERROR: There are no distributors currently
available</td></tr>"
End If
varA = numVariable
varB = CStr(varA)
Session("numTotalNumDistributors") = ""
Session("numTotalNumDistributors") = varB
rsDistributor.close
objconn.close
%>
<tr>
<td align="center" colspan="7"><br>
<input type="Submit" value="Update Product Info">
<input type="reset"></td>
</tr>
</table>
</body>
</form>
</html>
PAGE 2
<%
'Declare variables
Dim objconn
Dim strconn
Dim rsSelection
Dim sqlstmt
Dim varA
Dim varB
Dim numTotalRemaining
Dim numTotalSelected
varA = Session("numTotalNumDistributors")
varB = CLng(varA)
numTotalRemaining = varB
'Set up connection.
set objconn = Server.CreateObject("ADODB.Connection")
strconn = "File Name=" + Server.MapPath("access.udl")
objconn.Open strconn
'Set up new recordset and get information from database.
set rsSelection = Server.CreateObject("ADODB.Recordset")
rsSelection.CursorType = adOpenDynamic
rsSelection.LockType = adLockOptimistic
sqlstmt = "SELECT * FROM distributor_product_line"
rsSelection.Open sqlstmt, objconn
'Perform until numVariable is equal to zero.
Do While numTotalRemaining <> 0
'If the customer has selected that product then write a
new record.
If Request.Form(numTotalRemaining) <> "0" Then '<- HERE
IS THE PROBLEM
varA = Request.Form(numTotalRemaining) '<- HERE
IS THE PROBLEM
varB = varB
rsSelection.AddNew
rsSelection("dpl_distributor_number") = varB
varA = Session("strNewProductNumber")
varB = varA
rsSelection("dpl_product_number") = varB
rsSelection("dpl_date_created") = Date
varA = Chr(numTotalRemaining) '<- HERE
IS THE PROBLEM
varB = "txt"
varB = varB + varA
rsSelection("dpl_distributor_product_number") =
Request.Form("txt" + varB) '<- HERE IS THE PROBLEM
rsSelection.Update
numTotalRemaining = numTotalRemaining - 1
Else
numTotalRemaining = numTotalRemaining - 1
End If
Loop
Session("strCompInfo") = ""
Session("strCompInfo") = "Information Updated"
Response.Redirect("emp_new_completion.asp")
rsSelection.close
objconn.close
%>
PLEASE HELP
%%email.unsub%%
********************************************************************
The information contained in this email is confidential and
is intended solely for the use of the person identified and
intended as the recipient. If you are not the intended
recipient, any disclosure, copying, distribution, or taking of
any action in reliance on the contents is prohibited. If you
receive this message in error, contact the sender
immediately and delete it from your computer.
Personal e-mails are restricted by PSECU policy. As such,
PSECU specifically disclaims any responsibility or liability
for any personal information or opinions of the author
expressed in this email.
********************************************************************
Message #4 by "Subash Reddy(Ext 232)" <subash@d...> on Wed, 3 Apr 2002 09:46:39 +0800
|
|
Hello David,
Whichever u selected the form valus is not right.
u write like this.
If trim(Request.form("numVariable")) <> "" Then
something here................
End
u try this way maybe it will work
m s reddy
----- Original Message -----
From: DAVID GOBLE <DavidRGJR@h...>
To: ASP components <asp_components@p...>
Sent: Tuesday, April 02, 2002 9:45 PM
Subject: [asp_components] STUDENT NEEDS HELP
PLEASE................................
> http://p2p.wrox.com/post.asp?list=access_asp
>
>
>
> Okay everybody, I hope someone can help (BECAUSE MY TEACHER CAN'T)
> If you want to show your knowledge to a complete stranger and have him bow
> down to you please help me find a solution to this problem.
>
> I have two pages (all code shown below) that displays a list of products a
> user can select to have added to their 'shopping cart'. The problem is,
> how do you tell the second page to retrieve the values that the user has
> selected.
>
> I try to use the Request.Form() function but it tells me that the variable
> must have "" inorder to be retrieved.
>
> I know that this is difficult to ask over the web but at this point i am
> despirate and no one at my college can help me.
>
> <html>
>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <title></title>
> </head>
> <form method="POST" action="emp_verifyproddistributors.asp">
>
> <body>
> <u><b><font size="4"><font color="#02089E">Distributor
> Products</font></u><br>
> </font></b>
>
> <table border=0>
>
> <tr>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>Selection</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>Distributor</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>City</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>State</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>Zip</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2>If 'Add'ed,<br>Dist. Product #</font></td>
> </tr>
> <%
> 'Declare variables
> Dim objconn
> Dim strconn
>
> Dim rsDistributor
> Dim sqlstmt
>
> Dim varA
> Dim varB
> Dim numVariable
>
> numVariable = 0
>
> 'Set up connection.
> set objconn = Server.CreateObject("ADODB.Connection")
> strconn = "File Name=" + Server.MapPath("access.udl")
> objconn.Open strconn
>
> 'Set up new recordset and get information from database.
> set rsDistributor= Server.CreateObject("ADODB.Recordset")
> rsDistributor.CursorType = adOpenDynamic
> sqlstmt = "SELECT * FROM distributor_information"
> rsDistributor.Open sqlstmt, objconn
>
> 'Display all products for the user to select the correct products.
> If Not rsDistributor.EOF Then
>
> Do While Not rsDistributor.EOF
> numVariable = numVariable + 1
> Response.Write "<font size = 2><tr>"
> Response.Write "<td align = ""center"">"
> Response.Write "<select name = """
> Response.Write numVariable
> Response.Write """>"
> Response.Write "<option selected = ""selected""
> value = ""0"">Not Selected</option>"
> Response.Write "<option value = """
> Response.Write Trim(rsDistributor
> ("d_distributor_number"))
> Response.Write """>Add</option></td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor
> ("d_company_name"))
> Response.Write "</td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor("d_city"))
> Response.Write "</td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor("d_state"))
> Response.Write "</td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor("d_zip"))
> Response.Write "</td>"
> Response.Write "<td><center><input type=""text""
> id=""txt"
> Response.Write numVariable
> Response.Write """ size = ""10"" max length
> = ""50"" /></td>"
> Response.Write "</tr></font></center>"
> rsDistributor.MoveNext
> Loop
>
> Else
> Response.Write "<tr><td align=""center""
> colspan=""7"">ERROR: There are no distributors currently
> available</td></tr>"
> End If
>
> varA = numVariable
> varB = CStr(varA)
>
> Session("numTotalNumDistributors") = ""
> Session("numTotalNumDistributors") = varB
>
> rsDistributor.close
> objconn.close
> %>
> <tr>
> <td align="center" colspan="7"><br>
> <input type="Submit" value="Update Product Info">
> <input type="reset"></td>
> </tr>
> </table>
> </body>
> </form>
> </html>
>
> PAGE 2
>
> <%
>
> 'Declare variables
> Dim objconn
> Dim strconn
>
> Dim rsSelection
> Dim sqlstmt
>
> Dim varA
> Dim varB
> Dim numTotalRemaining
> Dim numTotalSelected
>
> varA = Session("numTotalNumDistributors")
> varB = CLng(varA)
> numTotalRemaining = varB
>
> 'Set up connection.
> set objconn = Server.CreateObject("ADODB.Connection")
> strconn = "File Name=" + Server.MapPath("access.udl")
> objconn.Open strconn
>
> 'Set up new recordset and get information from database.
> set rsSelection = Server.CreateObject("ADODB.Recordset")
> rsSelection.CursorType = adOpenDynamic
> rsSelection.LockType = adLockOptimistic
> sqlstmt = "SELECT * FROM distributor_product_line"
> rsSelection.Open sqlstmt, objconn
>
>
> 'Perform until numVariable is equal to zero.
> Do While numTotalRemaining <> 0
>
> 'If the customer has selected that product then write a
> new record.
> If Request.Form(numTotalRemaining) <> "0" Then '<- HERE
> IS THE PROBLEM
>
> varA = Request.Form(numTotalRemaining) '<- HERE
> IS THE PROBLEM
> varB = varB
>
> rsSelection.AddNew
> rsSelection("dpl_distributor_number") = varB
>
> varA = Session("strNewProductNumber")
> varB = varA
> rsSelection("dpl_product_number") = varB
> rsSelection("dpl_date_created") = Date
>
> varA = Chr(numTotalRemaining) '<- HERE
> IS THE PROBLEM
> varB = "txt"
> varB = varB + varA
> rsSelection("dpl_distributor_product_number")
> Request.Form("txt" + varB) '<- HERE IS THE PROBLEM
> rsSelection.Update
>
> numTotalRemaining = numTotalRemaining - 1
>
> Else
> numTotalRemaining = numTotalRemaining - 1
> End If
>
> Loop
>
> Session("strCompInfo") = ""
> Session("strCompInfo") = "Information Updated"
> Response.Redirect("emp_new_completion.asp")
>
> rsSelection.close
> objconn.close
> %>
>
>
> PLEASE HELP
>
%%email.unsub%%
>
Message #5 by Swathi <swathi@m...> on Wed, 03 Apr 2002 16:58:53 +0530
|
|
--------------E0C4D3900108EF1861B58466
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Hi David!
This is the way i understood ur problem
U have to display the items which have been selecetd in the previous page. Rite?
and u r using textbox to find out what item have u selected.
So here is the way i suggest
1st way
have a check box (i didnt find it in ur code) against each item. and when ever any
item is selected, the check box wud be checked and when u say
request.form("chkitem") (assuming chkitem is the check box name) , an array wud be
returned having all the items checked and u can get corresponding values in the
textboxes( Quantity i suppose).
u can check whether chkitem consists of any value using following code snippet
arrItemsselected=request.form("chkitem")
if isarray(arrItemsselected) then 'if multiple items are selected
arrItemsselected1=split(join(arrItemsselected,","),",") ' convert the
itemsselceted into an array for looping . check out whether split and join both r
necessary.
end if
for i=0 to ubound(arrItemsselected1)-1
Response.write Request.form("txt"&arrItemsselected1(i))
' to display the text box content of the previous page
' u can do the rest of inserting here
next
I can say from my under standing , what ever u r trying to do may not be fruitful
'If the customer has selected that product then write a
new record.
If Request.Form(numTotalRemaining) <> "0" Then
What are u trying to do here?
u shud say here the no of items <>0
numTotalRemaining in ur code does not resemble that any where
sorry! if i missed any thing
?<- HERE IS THE PROBLEM
varA = Request.Form(numTotalRemaining) ?<- HERE
IS THE PROBLEM
varB = varB what is this now?
I can help u for further clarifications
Regards,
Swathi Rama Lakshmi.Akella
DAVID GOBLE wrote:
> http://p2p.wrox.com/post.asp?list=access_asp
>
> Okay everybody, I hope someone can help (BECAUSE MY TEACHER CAN'T)
> If you want to show your knowledge to a complete stranger and have him bow
> down to you please help me find a solution to this problem.
>
> I have two pages (all code shown below) that displays a list of products a
> user can select to have added to their 'shopping cart'. The problem is,
> how do you tell the second page to retrieve the values that the user has
> selected.
>
> I try to use the Request.Form() function but it tells me that the variable
> must have "" inorder to be retrieved.
>
> I know that this is difficult to ask over the web but at this point i am
> despirate and no one at my college can help me.
>
> <html>
>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <title></title>
> </head>
> <form method="POST" action="emp_verifyproddistributors.asp">
>
> <body>
> <u><b><font size="4"><font color="#02089E">Distributor
> Products</font></u><br>
> </font></b>
>
> <table border=0>
>
> <tr>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>Selection</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>Distributor</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>City</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>State</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2><br>Zip</font></td>
> <td align="center"><font color="#02089E" face="Courier
> New" size = 2>If 'Add'ed,<br>Dist. Product #</font></td>
> </tr>
> <%
> 'Declare variables
> Dim objconn
> Dim strconn
>
> Dim rsDistributor
> Dim sqlstmt
>
> Dim varA
> Dim varB
> Dim numVariable
>
> numVariable = 0
>
> 'Set up connection.
> set objconn = Server.CreateObject("ADODB.Connection")
> strconn = "File Name=" + Server.MapPath("access.udl")
> objconn.Open strconn
>
> 'Set up new recordset and get information from database.
> set rsDistributor= Server.CreateObject("ADODB.Recordset")
> rsDistributor.CursorType = adOpenDynamic
> sqlstmt = "SELECT * FROM distributor_information"
> rsDistributor.Open sqlstmt, objconn
>
> 'Display all products for the user to select the correct products.
> If Not rsDistributor.EOF Then
>
> Do While Not rsDistributor.EOF
> numVariable = numVariable + 1
> Response.Write "<font size = 2><tr>"
> Response.Write "<td align = ""center"">"
> Response.Write "<select name = """
> Response.Write numVariable
> Response.Write """>"
> Response.Write "<option selected = ""selected""
> value = ""0"">Not Selected</option>"
> Response.Write "<option value = """
> Response.Write Trim(rsDistributor
> ("d_distributor_number"))
> Response.Write """>Add</option></td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor
> ("d_company_name"))
> Response.Write "</td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor("d_city"))
> Response.Write "</td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor("d_state"))
> Response.Write "</td>"
> Response.Write "<td align = ""center"">"
> Response.Write Trim(rsDistributor("d_zip"))
> Response.Write "</td>"
> Response.Write "<td><center><input type=""text""
> id=""txt"
> Response.Write numVariable
> Response.Write """ size = ""10"" max length
> = ""50"" /></td>"
> Response.Write "</tr></font></center>"
> rsDistributor.MoveNext
> Loop
>
> Else
> Response.Write "<tr><td align=""center""
> colspan=""7"">ERROR: There are no distributors currently
> available</td></tr>"
> End If
>
> varA = numVariable
> varB = CStr(varA)
>
> Session("numTotalNumDistributors") = ""
> Session("numTotalNumDistributors") = varB
>
> rsDistributor.close
> objconn.close
> %>
> <tr>
> <td align="center" colspan="7"><br>
> <input type="Submit" value="Update Product Info">
> <input type="reset"></td>
> </tr>
> </table>
> </body>
> </form>
> </html>
>
> PAGE 2
>
> <%
>
> 'Declare variables
> Dim objconn
> Dim strconn
>
> Dim rsSelection
> Dim sqlstmt
>
> Dim varA
> Dim varB
> Dim numTotalRemaining
> Dim numTotalSelected
>
> varA = Session("numTotalNumDistributors")
> varB = CLng(varA)
> numTotalRemaining = varB
>
> 'Set up connection.
> set objconn = Server.CreateObject("ADODB.Connection")
> strconn = "File Name=" + Server.MapPath("access.udl")
> objconn.Open strconn
>
> 'Set up new recordset and get information from database.
> set rsSelection = Server.CreateObject("ADODB.Recordset")
> rsSelection.CursorType = adOpenDynamic
> rsSelection.LockType = adLockOptimistic
> sqlstmt = "SELECT * FROM distributor_product_line"
> rsSelection.Open sqlstmt, objconn
>
>
> 'Perform until numVariable is equal to zero.
> Do While numTotalRemaining <> 0
>
> 'If the customer has selected that product then write a
> new record.
> If Request.Form(numTotalRemaining) <> "0" Then ?<- HERE
> IS THE PROBLEM
>
> varA = Request.Form(numTotalRemaining) ?<- HERE
> IS THE PROBLEM
> varB = varB
>
> rsSelection.AddNew
> rsSelection("dpl_distributor_number") = varB
>
> varA = Session("strNewProductNumber")
> varB = varA
> rsSelection("dpl_product_number") = varB
> rsSelection("dpl_date_created") = Date
>
> varA = Chr(numTotalRemaining) ?<- HERE
> IS THE PROBLEM
> varB = "txt"
> varB = varB + varA
> rsSelection("dpl_distributor_product_number")
> Request.Form("txt" + varB) ?<- HERE IS THE PROBLEM
> rsSelection.Update
>
> numTotalRemaining = numTotalRemaining - 1
>
> Else
> numTotalRemaining = numTotalRemaining - 1
> End If
>
> Loop
>
> Session("strCompInfo") = ""
> Session("strCompInfo") = "Information Updated"
> Response.Redirect("emp_new_completion.asp")
>
> rsSelection.close
> objconn.close
> %>
>
> PLEASE HELP
>
> To unsubscribe send a blank email to %%email.unsub%%
>
Message #6 by webmaster@c... on Tue, 9 Apr 2002 23:35:08
|
|
Hi David,
first of all, very nice coding style!
ok, here goes:
first, the <form> and </form> tags, a very important component of what
you are doing here, are below the <body> and </body> tags in the DOM. you
need to have
<body>
<form...>
</form>
</body>
NOT
<form>
<body>
</body>
</form>
Second, you need to understand what the HTML form does - it can carry
variables from one page to the next inside of the http header.
When you "submit" a form, the variables (and their values) that are in
the various html <input>, <select>, etc... DOM tags are placed in the
header ( in Server.QueryString for <form method="get"> and Server.Form for
<form method='post'> )
SO, if you want to carry a Variable/Value from one page to the next, you
have to:
1) write it out to the Form in a form <input>, <select> ,etc tag
OR
2) forge the HTTP Form Headers or the QueryString Headers, and carry the
info in the request for the next page.
Thats it.
You cannot put it in a database, nor in Session UNTIL YOU GET BACK TO
THE SERVER.
You can write the variable's contents out in the form in a hidden field:
Response.Write("<input type='hidden' name='variableA' value='" &
variableA & "'>")
( method 1)
OR add it to the QueryString for the next request (perhaps using Javascript)
A QueryString is a set of Name=Value Pairs ("=" delimited), seperated
by amperstands "&", and seperated from the http address/port by a "?"
example:
dim var1 = "Test"
dim var2 = 3;
to send this to RunThis.asp in the querystring, the URL would be:
http://www.server.com/RunThis.asp?var1=Test&var2=3
You will want to URLEncode the "var=..." part of the QueryString
before you send this..
*******************
Your problem was that you did not enclude your variables in the form nor
in the QueryString...
To get these out:
if you used method 1, using <form method='post'>
dim variableA = Request.Form("variableA")
method 2, or method 1 where <form method='get'>
dim var1 = Request.QueryString("var1")
dim var2 = Request.QueryString("var2")
*********
ON the second page, the one that carries data from the client to the
server, you could now use more persistant storage if you wanted (again,
this is done on the server, before the Response is sent out)
So Add:
3) Shove it into server memory IN THE USER'S CONTEXT (luckly ASP handles
the context for you in the Session Object)
OR
4) put it into persistant storage ( a database, etc)
ETC.....
***************************************
After all that (I did not want to give it away), the short answer is:
on the first page you need to write out:
Response.Write( "<input type='hidden' name='numTotalRemaining' value='"
& VariableHere & "'>")
so that your Form can carry the value of numTotalRemaining to the next
page, where Request.Form("numTotalRemaining") can pick it up.......
( and fix the <body><form></form></body> thing)
|
|
 |