Link to home
Start Free TrialLog in
Avatar of mattybrigh
mattybrigh

asked on

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.
Avatar of Silversoft
Silversoft

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-
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>
Avatar of mattybrigh

ASKER

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).
ASKER CERTIFIED SOLUTION
Avatar of ainapure
ainapure

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You the man, that worked perfectly!  Thanks Amit