> I'm trying to use a drop down list for the user to select an entery which
> will goo back to the database and grabs what the user selects then outputs a
> list using ConnectDatabase.asp. The problem is I don't know how to make input
> tags for a drop down
You just have to *NAME* the <select> (same as any other form field).
Example (and look at the first <option> that I added):
<select name="BedroomSize">
<optgroup label="Bedroom Size">
<option value=""> Any Size </option>
<option value = "Bachelor"> Bachelor </option>
... rest same ...
</select>
And how about adding this:
Show listings in what order?
<select name="orderby">
<option value="DatePosted DESC"> Date posted, recent first
<option value="DatePosted ASC"> Date posted, oldest first
<option value="Rent DESC"> Rent, highest first
<option value="Rent ASC"> Rent, lowest first
</select>
And then, in the page you post the form to, do this:
<%
... code ...
Dim reqBedroomSize, where, orderby
reqBedroomSize = Trim("" & Request("BedroomSize") )
where = ""
If reqBedroomSize <> "" Then
where = " WHERE BedroomSize = '" & Replace(reqBedroomSize, "'", "''" ) &
"' "
End If
' note that if user selected "any" for size, then there won't be a WHERE
clause
orderby = Trim( Request("orderby") )
sSQL = "SELECT DatePosted, Area, NearestIntersection, HousingType, " _
& " BedroomSize, Rent, Details " _
& " FROM TblHousing " _
& where _
& " ORDER BY [" & Replace(orderby, "'", "''") & "]"
... rest same ...
Emma - 06 Aug 2008 20:29 GMT
Thankyou so much, it's really simple and helpful!
> > I'm trying to use a drop down list for the user to select an entery which
> > will goo back to the database and grabs what the user selects then outputs a
[quoted text clipped - 44 lines]
> & " ORDER BY [" & Replace(orderby, "'", "''") & "]"
> ... rest same ...