I have a web form on a page called amTest.asp using a Select
dropdown. My Option Values are named the same as the fields in my
Database, example:
<form action="amTest.asp" name="searchAmenities" method="get">
<select name="searchAmenities">
<option>---Please Select an Option---</option>
<option value="soccer_fields">Parks With Soccer Fields</option>
<option value="recreation_center">Parks With Rec. Centers</option>
<option value="trails">Parks With Trails</option>
</select>
<input type="submit" value="Submit" />
</form>
There are about 15 other fields, but you get the idea.
In my Parks database I have fields
named "parks", "soccer_fields", "recreation_centers", "trails",
and "webify" (webify is a boolean of True or False), and about 15
others. If a particular park has one of the amenities listed in the
dropdown then there is an "x" to annotate it in the dbase, for
example if, in my dbase a Park has a soccer_field, then there is
an "x" in that field annotating soccer_field.
What I need to be able to do is pass the option value into my query,
so that it will look in the database for that amenity that was
selected, if it has an "x" AND if "webify" has been set to TRUE and
then return the results to this same page.
Here is the cruddy code I have that I know I'm not getting right. If
someone with better eyes can look at it and tell me what or where I
am going wrong, I would appreciate it. I am a novice, so please
don't use too high falutin' words on me. Rather walk me through the
error of my ways:
<%
Dim objDC, objRS
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
'Use this line to use Access
objDC.Open "DBQ=" & Server.MapPath("parks.mdb") & ";Driver=
{Microsoft Access Driver
(*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20 ;"
Set objRS = Server.CreateObject("ADODB.Recordset")
' Opening record set with a forward-only cursor (the 0) and in read-
only mode (the 1)
' If a request for a specific park amenity comes in, then do it
'If Len(Request.QueryString("searchAmenities")) <> "0" Then
' request records for requested search amenity from parks table
objRS.Open "SELECT * FROM parks WHERE ' & Request.Form
("'searchAmenities'") & ' = ""x"" ORDER BY park asc ", objDC, 0, 1
' Show selected record
If Not objRS.EOF Then
objRS.MoveFirst
End If
' Start This part writes out a picture only if their is a picture
associated with the Park Selected
If objRS.Fields("picture") = objRS.Fields("picture") Then
Response.Write "<p class=picturetext><img src=images/parks/"
& objRS.Fields("picture") & " width=220><br>" & objRS.fields
("picdescribe") & "</p>"
ELSE
Response.write "<p class=picturetext><img
src=images/parks/photo.jpg width=210><br><P
class=picturetext>Rolling Hills and Blue Skies is What Your Prince
William County Park Authority Has For You</P>"
End If
%>
<!-- End This part writes out a picture only if their is a picture
associated with the Park Selected -->
HERE is the form that searches and returns back to this page:
Search for Parks with:
<form action="amTest.asp" name="searchAmenities" method="get">
<select name="searchAmenities">
<option>---Please Select an Option---</option>
<option value="district">Parks By District</option>
<option value="recreation_center">Parks With Rec. Centers</option>
<option value="trails">Parks With Trails</option>
<option value="softball_fields">Parks With Softball Fields</option>
<option value="football_fields">Parks With Football Fields</option>
<option value="football_fields">Parks With Football Fields</option>
<option value="soccer_fields">Parks With Soccer Fields</option>
<option value="baseball_fields">Parks With Baseball Fields</option>
<option value="little_league_fields">Parks With Little League
Fields</option>
<option value="basketball_courts">Parks With Basketball
Courts</option>
<option value="tennis_courts">Parks With Tennis Courts</option>
<option value="picnic_pavilions">Parks With Picnic Pavilions</option>
<option value="pool">Parks With Pools</option>
<option value="playground">Parks With Playgrounds</option>
</select>
<input type="submit" value="Submit" />
</form>
Then, I should be able to write out the results from objRS.Fields.
The problem is that I get no returns from the Dbase. I know my code
is really malformed, but I would appreciate someone showing me how
the "objRS.Open "Select..." should look in order to make this
happen, or if I might have to do some other declarations, if you
could show me how that would work please. I'm very new to ASP, but
think I could provide something nice for the Public to see for our
Recreation Department.
Thank you,
Mark
mgordon AT pwcparks.org
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/