On 16 Jul 2012 at 21:19, Jen Rasmussen <j...@cetaceasound.com> wrote: 

> 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.

Well it would be. This approach doesn't scale.

> 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.

I doubt if you can read it from JavaScript.

> My questions are:
> 1) Do people just normally use hidden fields to store possible information
> to fill the drop downs?
> 2) any suggestions?

You could use ajax to request the information needed to load the second drop 
down. Once the user chooses their bank, then your JavaScript makes an ajax 
request to a PHP script that returns the clients list. You use this to populate 
the second drop down.

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to