[ciapug] Two dynamic drop downs

Chris Hettinger ciapug@cialug.org
Wed, 27 Oct 2004 18:37:41 -0500


I went with the second... in this case the select options and their 
values are not something I am concern about being seen, since it will 
you could see them in the sourse and I wasn't dealing with large numbers...

When I get a second I will clean up and comment the page/script and 
share it here.

-ch

Barry Von Ahsen wrote:
> David Champion wrote:
> 
>> Chris Hettinger wrote:
>>
>>> Perhaps someone has a solution to this,
>>>
>>> In a web form I have two drop downs that I need to build dynamically. 
>>> The first drop down is a main category and the second drop down box 
>>> is populated with appropriate options once the first drop down 
>>> selection has been made.
>>>
>>> This has to be done with some melding of JavaScript and PHP, but I 
>>> haven't found the best way to solve this yet.
>>>
>>> Just curious if anyone else had done something similar and could let 
>>> me of a good JS script to use or psuedo code of how they solved it.
>>>
>>
>> Barry recently did some javascript voodoo on the iowarealty.com web 
>> site to do rotating images... the PHP code builds a Javascript array, 
>> which loops thru the images. You could probably do something similar - 
>> load a javascript array, and in your onchange for the first control, 
>> have it load the second one from the array.
>>
> 
> ah, the joy of mixing client-side scripting with server-side scripting.
> 
> the two real options I've used (there may well be others) are either 
> build the first list, then when a choice is made, resubmit/reload the 
> page based on that selection.   downside: have to reload the page, save 
> state, form vars, etc, etc.
> 
> otherwise, load up the first list, and create every possible second 
> list, but hide it until the choice is made, then use javascript/dom foo 
> to show the appropriate second list.  downside: many multiple possible 
> secondary lists, long load time, having all the code in the source
> 
> six of one, half-dozen 'tother
> 
> -barry
> 
> 
> _______________________________________________
> ciapug mailing list
> ciapug@cialug.org
> http://cialug.org/mailman/listinfo/ciapug
>