RE: [PHP-WIN] How to make linked drop down box
| From: | Vail, Warren | Date: | Fri, 13 Feb 2004 18:04:01 +0000 |
| Subject: | RE: [PHP-WIN] How to make linked drop down box | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-22803@lists.php.net to get a copy of this message | ||
You have two selection lists, the contents of the second is determined by
the selection on the first. With PHP you have two choices, as I see it.
1. When a selection occurs on the first box, you force a form submit
(OnChange="this.form.submit();") and the php code puts together a new page
with the second list filled in with the contents that match the selection in
the first list.
2. You send all the contents with your form as a JavaScript array, and when
the user clicks on the first list, JavaScript code that you have included in
your form changes the contents of the contents of the second list.
The first solution is slower requiring a "round trip" to the server and
back, but is all PHP. The second is much faster, but requires a good
knowledge of JavaScript (many developers do not consider sending JavaScript
to the browser with their html, because they don't know JavaScript, but PHP
can handle that just fine).
hope this helps,
Warren Vail
-----Original Message-----
From: Haidong (Henry) Chen [mailto:myfeng@netzero.com]
Sent: Friday, February 13, 2004 9:36 AM
To: php-windows@lists.php.net
Subject: [PHP-WIN] How to make linked drop down box
Hi, there,
Could someone tell how to implement a two or more drop down list with parent
and child relationship between them?
What I need is something like the following. For example, if click on
country, we will see "US< Canada, France, etc". After click on "US", we can
see "Arizona, California, Florida, etc" in State box. After click on
California in State box, we can see " san Jose, San Francisco, Santa Clara,
etc" in City box.
Thank you in advance!
Henry
Position Type :
-- Select --
Country :
-- Select
--U.S.BelgiumChinaIndiaIsraelJapanNetherlandsSingaporeTaiwanUnited
KingdomKorea
State :
-- Select --
City :
-- Select --