Solved

Dynamic Drop Down Search

Posted on 2004-11-02
324 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
Question by:mattybrigh
    5 Comments
     
    LVL 2

    Expert Comment

    by: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-
    0
     
    LVL 2

    Expert Comment

    by:Silversoft
    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
    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:
    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
    You the man, that worked perfectly!  Thanks Amit
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    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…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    933 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now