Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dropdown..
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dropdown..

 Post Reply Post Reply
Author
phorne View Drop Down
Newbie
Newbie


Joined: 18 May 2003
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote phorne Quote  Post ReplyReply Direct Link To This Post Topic: Dropdown..
    Posted: 18 May 2003 at 10:05am

A am new to ASP and used the examples to create a Church site that lists churches for a area.  Now I want to provide a drop down list to list only certain tyoes of churches - I have the code working manually to display only one type - but now am trying to get a dropdown list to select a chruch type and then send that type to the code to display just those churches.

Would welcome some help for a new guy!!

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 2003 at 1:21pm

Do you already got the categories or you got to pull them out of a database?

If you already got them is as simple as this:

<form method="post" name="frmName" action="pagename.asp">

<select size="1" name="category">
  <option value="1">Category #1</option>
  <option value="2">Category #2</option>
  <option value="3">Category #3</option>
  <option value="4">Category #4</option>
</select>

<input type="submit" name="submit" value="submit">

</form>

FeRnAN
Back to Top
phorne View Drop Down
Newbie
Newbie


Joined: 18 May 2003
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote phorne Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 2003 at 3:09pm

See Highlight below in red - Where you see 'AME' - I need to put the variable from the drop down.  Can I do this on the same page or do I need to have the dropdown and then load this page?

 

<%
'Dimension variables
Dim adoCon    'Holds the Database Connection Object
Dim rsevent   'Holds the recordset for the records in the database
Dim strSQL   'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("midga.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=midga"

'Create an ADO recordset object
Set rsevent = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT church.* FROM church order by city, Denomination, church;"

'Open the recordset with the SQL query
rsevent.Open strSQL, adoCon

'Loop through the recordset
Do While not rsevent.EOF
If  (rsevent("Denomination"))= "AME" then  
 'Write the HTML to display the current record in the recordset
 Response.Write ("<br>")
 Response.Write ("<a href=""display_form.asp?ID=" & rsevent("ID") & """>")
 Response.Write (rsevent("Church"))
 Response.Write ("</a>")
' Response.Write ("&nbsp;&nbsp;&nbsp;")
' Response.Write (rsevent("Denomination"))
 Response.Write ("&nbsp;&nbsp;&nbsp;")
 Response.Write (rsevent("city"))
end if
 
 'Move to the next record in the recordset
 rsevent.MoveNext

Loop

'Reset server objects
rsevent.Close
Set rsevent = Nothing
Set adoCon = Nothing
%>

Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2003 at 8:37am

am not sure if i understand wot ya doin

but if ya want to have them choose from a dropdown box then it lists all related to wot they choose from the dropdown get rid of there

  • If  (rsevent("Denomination"))= "AME" then  

(remember to get rid of its "end if" aswell)

and change:

  • strSQL = "SELECT church.* FROM church order by city, Denomination, church;"

to:

  • strSQL = "SELECT church.* FROM church WHERE Denomination = '" & VarFromDropDown & "' order by city, Denomination, church;"

that will show a list of all the churchs that the "Denomination" Equals what was chosen from the DropDown

hope it helps

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.