Click to See Complete Forum and Search --> : Dynamic dropdown boxes
I am looking for help dynamically loading dropdown boxes. There are a couple scripts on this site that use the selection from the first dropdown to load the second box. All of these hard-code the options though. Is there a way to load the second box from a table where the query would use a variable which is the selection from the first box?
If you mean pull data from a database without reloading the page, you'll have to do it in Java or Flash.
[J]ona
Thanks for the response. The script titled DROPDOWN BOX POPULATION would be ideal if I didn't have to hard-code the values.
Tim
Originally posted by TimO
Thanks for the response. The script titled DROPDOWN BOX POPULATION would be ideal if I didn't have to hard-code the values.
You lost me there, my friend. Could you please provide the URL to the script of which you are speaking?
[J]ona
Sorry Jona. The script that is basically what I want is at http://javascript.internet.com/forms/dropdown-box-population.html.
Hmm, I see. Are you trying to populate the fields by pulling data from the server or from a database? If so, I'd suggest setting the JavaScript variable values according to what is taken from the server (kind of like a pre-loading concept).
[J]ona
Loading the first dropdown is no problem. The issue is filling the second dropdown from the database after a selection is made from the first dropdown.
Originally posted by TimO
Loading the first dropdown is no problem. The issue is filling the second dropdown from the database after a selection is made from the first dropdown.
I see, then you must be using a database to pull your information. Why not just fill in the possible values of the second dropdown menu in the JavaScript variables onload? Example in PHP (it would be a 2D array, as the code already probably uses):
var array_01 = new Array(new Array("<?php echo($variable_gotten_from_database); ?>"), new Array("<?php echo($variable2_gotten_from_database); ?>"));
[J]ona
I am new at HTML and have never touched a javascript but will give that a try.
Thanks again for the help.
Originally posted by TimO
I am new at HTML and have never touched a javascript but will give that a try.
Thanks again for the help.
Glad to be of assistance! Tell me how it works out, if it does. (Oh yes, I know you will be back with another question.) ;)
[J]ona