Re: Updating dropdown list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 6/11/2007 11:38 AM, Ashley M. Kirchner wrote:
I have a page containing two drop down lists. I need to figure out a way to populate/update the second drop down list based on a selection of the first one (the data for both drop down lists is in a MySQL database). Is this something I need to do in JavaScript? Or can I somehow trick PHP to do this?


I don't think you need to trick PHP -- it will be friendly and cooperative as long as you feed it some nice juicy strings from time to time.

The main difference between implementing this in javascript and implementing it in PHP is that PHP will require a round-trip to the server between menu changes, while javascript will act more immediately.

Because javascript is so commonly disabled, I write the logic first in PHP so that everyone can use the page, then again in javascript to enhance the experience for folks with scripting enabled. This is not a doubling of work: both scripts can utilize the same datasets (since PHP is downloading the page it can feed javascript a version of the same data it uses), and both scripts have very similar syntax (they're really cousins) so it's possible in many cases to write nearly identical logic in key functions, reducing programming, debugging, and maintenance time. This technique is known variously as 'unobtrusive javascript' and 'progressive enhancement.'

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux