|
 |
asp_databases thread: Getting value from <OPTION>
Message #1 by "Logan Scott" <p2pwrox@l...> on Sat, 12 Oct 2002 02:04:39
|
|
I am using an Access database to populate a list of <OPTION> values.
Along the lines of:
<% WHILE NOT rs.EOF %>
<OPTION=<%rs.field1%>><%rs.field1%>
<% website= rs.field2 %>
<% WEND %>
My problem is, the user sees the contents of the OPTION list correctly,
but what I need is for the variable website to be populated when they make
their selection. Basically, the rs.field1 shows on the screen, but I need
rs.field2 (Which in this case is the web site I want to send them to.)''
However, because I go through the whole recordset, the variable "website"
is always set to the last entry, and no matter what the user chooses, it
always sends them to that website.
How do I set the variable "website" when the user chooses a different
option???
Message #2 by "Shaun Larkin" <slarkin@m...> on Sat, 12 Oct 2002 14:10:50 -0400
|
|
As you noted, the variable will always be set to the last option in the list. So what you need to do is
post, using a 'form' the selection made by the user back to the same page. Retrieve the value from the Request object variable =
Request("your_field_name_goes_here").item. Use this value to do a lookup query on your database, and find the url value to redirect
them to. Use the Response.redirect("your_url_goes_here") method to send them to the correct page/website.
Good Luck.
---------- Original Message ----------------------------------
From: "Logan Scott" <p2pwrox@l...>
Reply-To: "ASP Databases" <asp_databases@p...>
Date: Sat, 12 Oct 2002 02:04:39
>I am using an Access database to populate a list of <OPTION> values.
>Along the lines of:
>
> <% WHILE NOT rs.EOF %>
> <OPTION=<%rs.field1%>><%rs.field1%>
> <% website= rs.field2 %>
> <% WEND %>
>
>My problem is, the user sees the contents of the OPTION list correctly,
>but what I need is for the variable website to be populated when they make
>their selection. Basically, the rs.field1 shows on the screen, but I need
>rs.field2 (Which in this case is the web site I want to send them to.)''
>
>However, because I go through the whole recordset, the variable "website"
>is always set to the last entry, and no matter what the user chooses, it
>always sends them to that website.
>
>How do I set the variable "website" when the user chooses a different
>option???
>
Message #3 by "Logan Scott" <p2pwrox@l...> on Sun, 13 Oct 2002 02:35:17
|
|
> As you noted, the variable will always be set to the last option in the
list. So what you need to do is post, using a 'form' the selection made
by the user back to the same page. Retrieve the value from the Request
object variable = Request("your_field_name_goes_here").item. Use this
value to do a lookup query on your database, and find the url value to
redirect them to. Use the Response.redirect("your_url_goes_here") method
to send them to the correct page/website.
Good Luck.
---------------------------------------------------
OK, how do I accomplish this? I have rs, which is now sitting on the last
record, and I want to lookup the value, but how do I do that? Sorry to be
sucha pest....
|
|
 |