Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

dropdown box dynamic

Options
  • 05-10-2009 11:53am
    #1
    Registered Users Posts: 8,070 ✭✭✭


    I'm loading dropdown box's values from a database, but on select i want to populate another dropdown box with corresponding values

    eg: if some one pics food in the first dropdown box, the next dropdown box will populate it with all the foods from the database


Comments

  • Registered Users Posts: 8,488 ✭✭✭Goodshape




  • Registered Users Posts: 8,070 ✭✭✭Placebo


    did you even read my post?
    il need to use ajax or something similar along side php.

    i think this may suffice
    http://roshanbh.com.np/2008/01/populate-triple-drop-down-list-change-options-value-from-database-using-ajax-and-php.html


  • Registered Users Posts: 1,322 ✭✭✭Mad_Max


    JQuery is the way to go. Have a google around for AJAX with JQuery.


  • Registered Users Posts: 1,322 ✭✭✭Mad_Max


    Placebo wrote: »

    The javascript could and should be a lot better that that imo.


  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    Placebo wrote: »
    did you even read my post?
    il need to use ajax or something similar along side php.
    Not that your post mentioned anything about either AJAX or PHP but yeah, whatever.. my mistake.

    Here, let me Google that for you.
    http://www.google.ie/search?q=dropdown+box+dynamic+ajax+php


  • Advertisement
  • Registered Users Posts: 8,070 ✭✭✭Placebo


    Thanks goodshape, with google there clearly is no need for message boards.


  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    Well what do you want? Someone to come on here and do your work for you?

    If you have a problem implementing a particular script - post it up, highlight where you're encountering problems, and I'm sure someone will help.

    From a starting point of "I need a script that does dynamic drop-downs" then yeah, I think Google should be your first port of call. It's a fairly common piece of functionality.


  • Registered Users Posts: 8,070 ✭✭✭Placebo


    obviously looking for an algorithm or what technology to use.
    Google was obviously my first port of call but after extensive searching and disregarding all the asp examples i thought i ask here.


  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    Well, apologies for being sarky tbh. Your original post could have been a bit clearer :p. I like helping people on here but not when it appears they couldn't be bothered to do so much as a google search beforehand.

    Anyhow, yeah - this shouldn't be too difficult with php and ajax. Easier again if you're using jQuery.

    What you'd want to do is make a post request triggered by the selection of an item in your initial dropdown. Then populate the subsequent dropdown based on an XML responce you get back.

    I'm fairly sure a google search along the lines of 'dynamic dropdown php ajax' will get you some good results.


  • Registered Users Posts: 8,070 ✭✭✭Placebo


    could have explained it well i guess, thanks
    there is a slight lag with ajax moving back and forth,
    will give jquery ago for sure

    although i think if i load all the data in different arrays then it may be quicker, using ajax ofcourse, wont need to query db each time then


  • Advertisement
  • Closed Accounts Posts: 1,200 ✭✭✭louie


    there is an example we put togheter a long time ago:

    http://www.eire-webdesign.ie/blog/2007/11/13/dependant-select-box-using-ajax/


  • Registered Users Posts: 8,070 ✭✭✭Placebo


    thanks louie !


Advertisement