PDA

Click to See Complete Forum and Search --> : Dropdown box!!


turfbult
Sep 11th, 2000, 01:28 PM
Hi,
I am VERY,VERY new to asp-ado and need some help please.

I want to put a dropdown box on my page with all the different countries as options. The user can then choose the country he wants to view and I want to then
select * from table where country = "the country the user picked from the dropdown"

My problem is how to get whatever the user selected into a variable which I can then use in my sql query

Thank you,

asabi
Sep 12th, 2000, 01:25 AM
you will have to use two pages:

1. with a regular HTML extention that will have a form:

<html>
<head><title>My Country</title></head>
<body>
<form method="post" action="showinfo.asp">
Please choose the country:
<select name="thecoutry">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<input type="submit" value="go">
</form>
</body>
</html>

2.

The ASP page (showinfo.asp)

<%
dim CountryName

CountryName=trim (request.form ("thecountry")) ' this will get the name of the country the user choosed on the previous page

strSQL = "set rowcount 0 select country from CountryTable where country=" & CountryName

....
%>

Hope it helped..

monte96
Sep 12th, 2000, 10:33 AM
It depends.. Where do you need the data from the query to be displayed? If you need it on the same page, you can setup an event for the select tag that reloads the page passing the value of the select with a querystring back to itself. In the beginning code of the page, check for the existence of the querystring and use it in the query.

If you need it in another page, add a submit button and set the action attribute to the new page and a method=post in the FORM tag. Make sure you use the name attribute in your select tag or you won't be able to get the data out of the Form collection.