Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can I use PHP to display drop down list based on another drop down list?

    Hi all!

    I'd like to have 3 drop down lists connected.

    Division
    Department and
    Section

    Where the options of Department are dependent on what is selected in Division and the options of Section are dependent on what is selected in Department.

    So far, all the examples I've found have been using JavaScript. Can I do this in PHP as I have no knowledge of JavaScript at all!

    If so, can someone please show me some sample code or direct me to more information?

    Thanks a bunch!

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    The problem with PHP is that the page has to reload to get the sub-catagories. With JavaScript sub-catagories are displayed instantly, which is way better.

    JavaScript is easy to learn and I recommend you use JavaScript in this case. You will need to know JavaScript for Ajax, which has lots of potential.
    Leonard Whistler

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Len,

    Thank you for your quick reply!

    How would I incorporate JavaScript into my PHP file?

  • #4
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Sherrie View Post
    Len,

    Thank you for your quick reply!

    How would I incorporate JavaScript into my PHP file?
    I'm not on my home computer for exact syntax but you can have javascript code outside of php code:

    PHP Code:
    <?php
    ?>
    Javascript code
    <?php
    ?>
    OR

    Use php to echo the javascript code.
    Leonard Whistler

  • #5
    New Coder
    Join Date
    Jan 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks again!

    Would you be able to recommend any Javascript resources?

    I have the sample code for linking the 2 combo boxes, but I don't understand most of it!

    Sorry to be such a pain

  • #6
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Sherrie View Post
    Thanks again!

    Would you be able to recommend any Javascript resources?

    I have the sample code for linking the 2 combo boxes, but I don't understand most of it!

    Sorry to be such a pain

    Post in the Javascript forum here on CodingForums. They will have you up and running very quickly.
    Leonard Whistler

  • #7
    New Coder
    Join Date
    Jan 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Will do that!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •