#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    I need to build a dynamic page with 2 drop down boxes on it where the contents of the second drop down box are dependent upon the selection made in the first drop down box (the first box contains districts/regions and the second box contains towns/cities). The customer wants this to happen on a single screen but can this be done with PHP?
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    No ,
    You should use client side scripting for this(Java Script).



    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    You can't do it unless you submit the form whenever they select the first value. You would have to use javascript for this.

    In combobox1, when a user selects a values, it automatically submits the form. On the second page, you evaluate what the user chose, then create the second combobox based on the value of the first. Then show both boxes again...

    A lot of sites use code like this, i think it's the only way to do it. you can actually do this all in one page (the action of your form being $PHP_SELF) so the submit process would be a pretty short time...

    ---John Holmes
  6. #4
  7. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    There's a working example at http://www.carphonewarehouse.com/nav...mod_frames.asp - see if you can figure out how they do it

    --------------------------------
    Alex
    (http://www.alex-greg.co.uk)
  8. #5
  9. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>The customer wants this to happen on a single screen

    As others mentioned, you need to use javascript (without loading the page) on the same page.

    Go to -> http://www.essex1.com/people/timothy/js-index.htm and click "RB LEAP TO 3".

    This example uses checkbox and textarea, you need alter it to make both a drop-down menu.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    I do this using javascript at www.bugteeth.com

    PHP generates <select> boxes and a javascript array. On select of the first box, javascript is called that loads new values into the second select box from the javascript array.

    ------------------
    ----------------------
    Ulysses J Ludwig
    Consultant
    Ujludwig@yahoo.com
    213.948.8278
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    Thanks people - you've given me enough to get on and do it.

  14. #8
  15. No Profile Picture
    ads
    Guest
    Devshed Newbie (0 - 499 posts)
    Looking at PHP handicap at Client side, I would like to write to developers of PHP to develope client side module in PHP which will have capabilities of Javascripts, Java Applets, Etc. Can anyone tell me where to contact them.
  16. #9
  17. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    Client side PHP? Now that would be nice...It's be so nice to refer to a text box as $text instead of window.document.form.text.value etc..etc....

    it'll probably never happen, but it's interesting....
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    This has surfaced again.

    Another solution I thought of would be to call the same PHP script if the selection in the first box changed - it would need to pass the contents as a parameter in the URL. Is this possible? I've been surfing the javascript sites but can't find what I need.

    Thanks in advance.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Create your first select form with onClick="document.formname.submit()" in the select tag where formname is the name you have given to your form and $PHP_SELF as the action then you will have the choice they selected after you submit then I assume you will mkae a query based on the choice and draw up another select box. Hope that helps.

Similar Threads

  1. dynamic drop down list using jsp in javascript
    By quilla_b in forum JavaScript Development
    Replies: 2
    Last Post: May 27th, 2004, 11:35 AM
  2. MySQL output to table using phpBB
    By CCCMTech in forum PHP Development
    Replies: 0
    Last Post: February 2nd, 2004, 02:43 PM
  3. How can I fill drop down boxes from external javascript?
    By MiaMandy in forum JavaScript Development
    Replies: 3
    Last Post: January 26th, 2004, 06:17 AM
  4. Missing spaces in variable - drop down boxes
    By tickled_pink in forum PHP Development
    Replies: 2
    Last Post: October 2nd, 2003, 06:36 AM
  5. dynamic drop down list for CF
    By bluepud in forum ColdFusion Development
    Replies: 3
    Last Post: September 8th, 2003, 10:08 AM

IMN logo majestic logo threadwatch logo seochat tools logo