On Jul 16, 2012, at 4:16 PM, Ramiro Barrantes <ramiro@xxxxxxxxxxxxxxxxxxxxx> wrote: > Hello, > > I am making an application using PHP/Javascript/mysql and had a question. > > Sometimes I need to use javascript to fill a drop down box based on the value of a previous drop down box. However, the information to fill the latter is stored in mysql and can be a lot, what I have been doing is that, using PHP, I create hidden fields with all the possible information that might be needed to fill the second drop down. > > For example, the user chooses a bank from a drop down, and then a list of clients is displayed on the following drop down. I use PHP to read all clients from all the banks and put that as hidden fields on the html page. It is very cumbersome. > > I do not want to read the database (which changes dynamically) from javascript directly due to confidentiality and because a lot of care has been taken to create the appropriate queries with checks and protect misuse of the information using PHP. > > My questions are: > 1) Do people just normally use hidden fields to store possible information to fill the drop downs? > 2) any suggestions? > > Thanks in advance, > Ramiro > Ramiro: The subject line of "Creating drop-down menus" is misleading -- here is what a "drop-down menu" is: http://sperling.com/examples/new-menuh/ http://sperling.com/examples/menuh/ And similarly, a "fly-out menu": http://sperling.com/examples/menuv/ What you are describing is simply a self-updating selection control, like this: http://php1.net/a/zipcode-states/ The description and code is there. To the PHP gang: As for the discussion re jQuery and such, there's no need -- it was not used in this demo. IOW, no jQuery was harmed. I am not against jQuery, on the contrary I think it's great, but it's not always needed for client-side functionality. As I see it, there is no need for a sledgehammer to drive a thumb tack. Please realize that all controls (input, textarea, options, selections, checkboxes, radio buttons, multi-options, etc.) can be handled this fashion. This is not your father's limited server-side php, but rather a coupling of both server-side and client-side languages to provide a more desktop-application-like user experience. Cheers, tedd _____________________ tedd@xxxxxxxxxxxx http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php