Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown box not populating

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm totally, totally new at this ADO/ASP stuff. Does anyone have any idea as to why my dropdown isn't populating? The variables txtAddr and txtZip come from text boxes in a form on the previous page. I'd appreciate in help in layman's terms. Thanks!!!! Here is my code:

<%

'Declaration of Variables
Dim cnnSearch ' ADO connection
Dim rs ' ADO Recordset
Dim strDBPath ' path to Access database (*.mdb) file

Dim strSQL ' The SQL Query built on the fly
Dim strSearchAddr ' The House Number being looked for
Dim strSearchZip ' The Zip Code being looked for

strSearchAddr = Request.Form(&quot;txtaddr&quot;)
strSearchZip = Request.Form(&quot;txtzip&quot;)
%>

<HTML>
<HEAD>
<TITLE>Polling Places</TITLE>
</HEAD>

<BODY bgcolor=&quot;white&quot; text=&quot;black&quot;>
<br><br>
<font face=&quot;arial&quot; size=&quot;5&quot;>
To help you locate the correct Polling Place based on the Address and Zip Code of your place of residence, I need to know your address and zip code.
Please select your address from the drop down lists below.</font>

<center>
<table width=&quot;98%&quot;>
<tr><td>
<%
If strSearchAddr <> &quot;&quot; AND strSearchZip <> &quot;&quot; Then
strDBPath =&quot;c:\Inetpub\
Set cnnSearch = Server.CreateObject(&quot;ADODB.Connection&quot;)
cnnSearch.Open &quot;Provider=MSDASQL.1;Persist Security Info=False;Data Source=vote&quot;

' Build query based on the input.
strSQL = &quot;SELECT PRP_ADDR, PRP_ZIP, POLLING, POLL_ADDR, POLL_CITY, LOCATION &quot; _
& &quot;FROM POLLING_PLACES &quot; _
& &quot;WHERE PRP_ADDR LIKE '&quot; & Replace(strSearchAddr, &quot;'&quot;, &quot;''&quot;) & &quot;%' &quot; _
& &quot;AND PRP_ZIP LIKE '&quot; & Replace(strSearchZip, &quot;'&quot;, &quot;''&quot;) & &quot;' &quot; _
& &quot;ORDER BY PRP_ZIP;&quot;

Set rstSearch = cnnSearch.Execute(strSQL)
%>
<form action=&quot;GetPlace.asp&quot; method=&quot;post&quot;>
<select name=&quot;AddrDown&quot;>
<% 'Loop through the recordset, creating a list item for each.%>

<% do while not rstSearch.eof%>
<Option Value=&quot;<%= rstSearch.Fields(&quot;PRP_ADDR&quot;).Value %>&quot;>
</Option>
<%rstSearch.movenext
loop%>

</select>
<br><center><input type=&quot;submit&quot; value=Submit></center>
</form>

</td></tr>
</table>
<p>
</center>
<%
' Close our recordset and connection and dispose of the objects
rstSearch.Close
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End If

%>
</BODY>
</HTML> [sadeyes]
 
Try this:

<% do while not rstSearch.eof%>
<Option><%= rstSearch.Fields(&quot;PRP_ADDR&quot;).Value %>
</Option>
<%rstSearch.movenext
loop%>
 
Hi ...
both of you are right but we have to mix the two codes to work :

Try this:

<% do while not rstSearch.eof%>
<Option Value=&quot;<%= rstSearch.Fields(&quot;PRP_ADDR&quot;).Value %>&quot;><%= rstSearch.Fields(&quot;PRP_ADDR&quot;).Value %>
</Option>
<%rstSearch.movenext
loop%>


----
TNX.
E.T.
 
OIC,

I forgot to assign a value to the option, sorry.

ivo
 
Thanks ehsant that worked perfectly! I'd post this as expert with a star, but another response came in before I could. But, I wanted to thank you for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top