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='a uthor.asp? type=' + this.options[this.selected Index].val ue;">
<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("a uthor")) & """><B>" &typers("author")&"</b></o ption> ")
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.
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='a
<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("a
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.
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='a uthor.asp? type=' + this.options[this.selected Index].val ue;">
<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("a uthor")) & "'>" & typers("author")& "</option>")
typers.movenext
loop
set typers = nothing
%>
</select>
</form>
<form>
<select name="type" onchange="location.href='a
<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("a
typers.movenext
loop
set typers = nothing
%>
</select>
</form>
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You the man, that worked perfectly! Thanks Amit
Try this:
response.write ("<option value='" & Server.urlencode(typers("a
I change the use of "'s, I dont think it is correct. So try the above and see if it works...
regards-