Home > ASP Development > Forms - ASP Making Dropdowns Dynamic

Forms - ASP Making Dropdowns Dynamic



I have a form on a page which at this point is simple named *.asp with no scripts attached. A form lives on the page that passes to another page/asp script to add the form fields to an Access database.



In the form, amongst others, I have two dropdowns (see simple code below). My question is: What is the best way to dynamically pull up the correct single value in the second dropdown, or display the single correct value--maybe it needs to display as a text input--based on the selection made in the first? For example if pack 2 is selected, then pack 2's price should be dynamically loaded. It will be the only code on the page for now.




Code:



<p>Select Program: <br>
<select size="1" name="packs">
<option value="Pack1">Pack1</option>
<option value="Pack2">Pack2</option>
<option value="Pack3">Pack3</option>
<option value="pack4">Pack4</option>
<option value="Pack5">Pack5</option>
<option value="Pack6">Pack6</option>
</select>/P

<p>Fees/Price: <br>
<select size="1" name="fees">
<option value="1">Pack1 $1.00</option>
<option value="2">Pack1 $2.00</option>
<option value="3">Pack1 $3.00</option>
<option value="4">Pack1 $4.00</option>
<option value="5">Pack1 $5.00</option>
<option value="6">Pack6 $6.00</option>
</select></p>






Thanks for any ideas...

    
Guest


try going here



Hope this helps

Was this answer helpful ? Yes No   
Guest


Thanks again...I thought that a client side solution would be the ticket. Let me see how I can utilize that code.

Was this answer helpful ? Yes No   
Guest


And perhaps this may hopefully give you some ideas. It's got a downloadable sample and does retain values after the post back:



Classic ASP Design Tips - Dependent Listboxes

http://www.bullschmidt.com/devtip-dependentlistboxes.asp

Was this answer helpful ? Yes No   
Guest


And for some client-side solutions:



Dynamic Select Menus

http://www.amerirus.com/tutor.html

Initially sends all data to the page and then lets JavaScript populate the second list box.

Uses as stringSplit JavaScript function that parses out things in array. Everything before * is for the first list box and each subsequent item between |'s is an item for the second list box.



Creating Dynamic JavaScript with ASP and Databases by Travis Giggy

http://www.15seconds.com/issue/000210.htm

Has examples of ASP code within JavaScript code and things that JavaScript can do.

But does not update a listbox based on another listbox.

Was this answer helpful ? Yes No   
Guest


Thank you for the help. I implemented a javascript solution, which for a couple of dropdowns works well...

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved