4 Replies Latest reply: Jul 26, 2012 12:54 PM by dips045 RSS

    ASP dynamic drop down

    dips045 Community Member

      Hi

       

      I have a table in a database and I would like to populate a dropdown menu along with some fields from this table. When the user selects an option from the drop down menu I want the description to change as well.

       

      I have dynamically populated the drop down menu but I am having difficulty in having the corresponding description change.

       

      <select name="date" id="date">

             <% DO WHILE NOT objRS.EOF %>

             <option onchange="<% Response.Write objRS("id") %>" value="<% Response.Write objRS("date") %>"><% Response.Write objRS("date") %><input name="id" type="hidden" value="<% Response.Write objRS("id") %>" /></option>

                     <%

                         objRS.MoveNext

                                Loop

                      %>

                    </select>

       

      Also I'm not sure how to update the information when an option is selected from the drop down menu without having to submit the from?

       

      Hope some one can help!

       

      Many thanks....

        • 1. Re: ASP dynamic drop down
          bregent MVP

          If you want data on the page to change without resubmitting, you would need to use client side javascript. Since the javascript array would be populated from server side data, you need to use AJAX methods to transfer data between server and client code.  You might search for something like 'transfer recordset to javascript array' to find a specific example.

          • 2. Re: ASP dynamic drop down
            dips045 Community Member

            thanks bregent....

             

            how do I retrieve the description based on the what is selected from the drop down list?

             

            I can search in a database if I had to submit the form and retrieve information but I have never used a drop down list so would like some assistance.

             

            many thanks again...

            • 3. Re: ASP dynamic drop down
              bregent MVP

              A form just posts the values from the fields it contains -including dropdowns - to a script. In the script you retrieve that posted value into a variable which you then use in a SQL statement WHERE clause. But it's still not clear what you are trying to do. If you are populating the dropdown from the database, then you can get the description at that time. Where are you trying to display the description?

              • 4. Re: ASP dynamic drop down
                dips045 Community Member

                I have two columns in my table, date and venue. The dates are listed in the drop down list. When I select a date I also want the corresponding venue to appear too... I'm having trouble showing this.

                I have populated the dynamic drop down list. Im struggling with the next bit.....