Skip to main content
Known Participant
July 25, 2012
Question

ASP dynamic drop down

  • July 25, 2012
  • 1 reply
  • 1297 views

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....

This topic has been closed for replies.

1 reply

Participating Frequently
July 25, 2012

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.

dips045Author
Known Participant
July 26, 2012

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...

Participating Frequently
July 26, 2012

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?