Dynamic Drop Down Search

Totally easy question, yet I can't seem to find any reliable code that will make it work.

Essentially, I want to have a drop down box populated dynamically from my DB.  I have that code:

<form>
<select name="type" onchange="location.href='author.asp?type=' + this.options[this.selectedIndex].value;">
<option value="">--Select author--</option>
<%
sql = "SELECT distinct author from newreviews order by author asc"
'sql = "SELECT reviewid from newreviews"
set typers = conn.execute(sql)
do while not typers.eof
response.write("<option value=""" & Server.urlencode(typers("author")) & """><B>" &typers("author")&"</b></option> ")
      typers.movenext
loop
set typers = nothing
%>
</select>
</form>

Though the Server.URLencode seems to be giving me an error.  

Does anyone have any generic code that will make this work?  All I want to do is have a drop down list with a "Submit" button that will return all of the author's reviews (titles) once clicked.  and I'm stumped.
mattybrighAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SilversoftCommented:
Hi

Try this:

response.write ("<option value='" & Server.urlencode(typers("author")) & "'>" & typers("author")& "</option>")

I change the use of "'s, I dont think it is correct. So try the above and see if it works...

regards-
0
SilversoftCommented:
The way you doing it, has the correct logic.... so i think it jsut some syntax error, here's the code for the whole thing::


<form>
<select name="type" onchange="location.href='author.asp?type=' + this.options[this.selectedIndex].value;">
<option value="">--Select author--</option>
<%
sql = "SELECT distinct author from newreviews order by author asc"
'sql = "SELECT reviewid from newreviews"
set typers = conn.execute(sql)
do while not typers.eof
response.write ("<option value='" & Server.urlencode(typers("author")) & "'>" & typers("author")& "</option>")
     typers.movenext
loop
set typers = nothing
%>
</select>
</form>
0
mattybrighAuthor Commented:
I dunno...I still get the same error.  Odd thing is that I have this exact same code working on another part of my site that searches the studio (so all I did was a find and replace on studio and change it to author).
0
ainapureCommented:
Here ya go!

***************CODE START***********
<form>
<select name="type" onchange="location.href='author.asp?type=' + this.options[this.selectedIndex].value;">
<option value="">--Select author--</option>
<%
sql = "SELECT distinct author from newreviews order by author asc"
'sql = "SELECT reviewid from newreviews"
set typers = conn.execute(sql)
if not typers.eof then
   While not typers.eof
%>
<option value='<%=typers("author")%>'><%=typers("author")%></option>
<% typers.movenext
wend
end if
set typers = nothing
%>
</select>
</form>
******************CODE END****************

Let me know if this works

-Amit
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mattybrighAuthor Commented:
You the man, that worked perfectly!  Thanks Amit
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.