Print Page | Close Window

Dropdown..

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2814
Printed Date: 29 March 2026 at 7:40pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Dropdown..
Posted By: phorne
Subject: Dropdown..
Date 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!!




Replies:
Posted By: fernan82
Date 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
http://www.danasoft.com/">


Posted By: phorne
Date 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
%>



Posted By: Scotty32
Date 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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net