Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic Drop Down Search

Posted on 2004-11-02
5
Medium Priority
?
338 Views
Last Modified: 2008-03-03
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.
0
Comment
Question by:mattybrigh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Silversoft
ID: 12473740
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
 
LVL 2

Expert Comment

by:Silversoft
ID: 12473807
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
 

Author Comment

by:mattybrigh
ID: 12473897
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
 
LVL 4

Accepted Solution

by:
ainapure earned 2000 total points
ID: 12474242
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
 

Author Comment

by:mattybrigh
ID: 12474659
You the man, that worked perfectly!  Thanks Amit
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question