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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Dynamic Select Box Generation

    Hello everyone,
    I'm interested in creating two drop down boxes on my html form that are populated with data from a mysql database. The data for the first box is course titles and the data for the second is course sections. So far this is no problem.

    BUT, since the data in both select boxes is related (ie. each course title has a corrresponding course section)...I would like the user (ie. the student) to be able to select either/or and have the other select box automatically pick the associated value from the mysql database.

    Anyone know how to approach this?

    thanks,
    sage

  • #2
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    This has to be done with javascript if you dont want an overly complicated solution. The first menu has to be a jump menu that reloads the page with a GET var using javascript. The second menu takes the GET var and uses it in the WHERE clause of the query whose resultset populates the 2nd drop menu.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You could do it with AJAX to avoid reloading the page, or populate a Javascript array on pageload and just reference it when the menu changes(if your menu isn't ridiculously large).

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    The first menu has to be a jump menu that reloads the page with a GET var using javascript.
    The issue is that most people who use these kind of forms find the experience unpleasant. So I'd recommend against this method.


  •  

    Posting Permissions

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