RE: How to make linked drop down box

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

 



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@xxxxxxxxxxx]
Sent: Friday, February 13, 2004 9:36 AM
To: php-windows@xxxxxxxxxxxxx
Subject:  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 --

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux