Avatar of Russell Scheinberg, MCSE Business Intelligence
Russell Scheinberg, MCSE Business Intelligence
Flag for United States of America asked on

How do I load a dynamic array from a SQL query into multiple pull down inputs on a classic ASP page?

Greetings all,

I am trying to figure out the best way to load the same dynamically generated (from a SQL server query) list into multiple pull down (select) input form objects on a classic ASP page. I think it might require a combination of vbscript  (to query the database) and javascript (to hold and display the pull down).  The sql query would look like this:

SELECT ListID, Symbol FROM Deals WHERE Active = 1

This would give me an array of unkown rows with ListID and Symbol pairs.

I then have a form with multiple (20) rows and each row needs to have the values of this array loaded into a pull down for one of the entries.

<select name="selDeal" id="selDeal">
<option value="ListID value from array">Symbol value from array</option>
</select>

I began to work on this but realized there might be a simple way to do it and I might not have to re-invent the wheel to do it if someone has already dealt with this scenario.

Thanks.
Microsoft SQL ServerASPJavaScript

Avatar of undefined
Last Comment
Scott Fell

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Scott Fell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Zberteoc

You will have to create a drop down control for each row and each with different name. Imagine this. On each row you have selected a different value from the list, which you will have then to post to the server. You need to be able to come up wit h the values for each row so basically the name of the drop down object will have to reflect or to be related somehow to the row, like a unique id/value per row.
Scott Fell

This solution  has some good info for getrows http:Q_28366983.html
Scott Fell

I'm not sure I totally understand what you need, but if you need multiple dropdowns where one is dependent on the other, I like to use jquery chained http://www.appelsiini.net/projects/chained
 
The set up is easy. From the sample on their page, you can see taht the value of the first select is equal to the class of the second.  When you select the first one, then only the choices with the matching class will be available in the 2nd.  You can generate the options just as I sampled originally.  
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.chained.min.js"></script>
<select id="mark" name="mark">
  <option value="">--</option>
  <option value="bmw">BMW</option>
  <option value="audi">Audi</option>
</select>
<select id="series" name="series">
  <option value="">--</option>
  <option value="series-3" class="bmw">3 series</option>
  <option value="series-5" class="bmw">5 series</option>
  <option value="series-6" class="bmw">6 series</option>
  <option value="a3" class="audi">A3</option>
  <option value="a4" class="audi">A4</option>
  <option value="a5" class="audi">A5</option>
</select>

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Russell Scheinberg, MCSE Business Intelligence

ASKER
Thanks all for responding. This was exactly the answer I needed. Works perfectly! Saved me a lot of time. Thank you, Scott!
Scott Fell

Glad it worked!  

Sometimes for larger arrays, I like to assign variables to help me remember what goes where instead of 0,1,2...

<%
For r = LBound(arrData, 2) To UBound(arrData, 2)
    ListID     = arrData(0,r)
    Symbol = arrData(1,r)

%>
    <option value="<%=ListID%>"><%=Symbol%></option>	
<%
next
%>

Open in new window