surajkandukuri Posted December 3, 2009 Share Posted December 3, 2009 Hi, This is not new but I am hard finding a solution to the problem , I have 3 drop down boxes, 1st drop down box displays the values from database, based on the value selected 2nd drop down boxes displays values and similarly 3rd drop down box Also I need to have all the values selected in the drop down boxes. Please help me Quote Link to comment https://forums.phpfreaks.com/topic/183882-three-dependent-drop-down-boxes-with-data-from-mysql-database/ Share on other sites More sharing options...
minidak03 Posted December 3, 2009 Share Posted December 3, 2009 If all your data is stored in the database what you'll need to do is use JavaScript and AJAX to dynamically generate that data. Have a look at the example below. <script type="text/javascript"> function fire_ajax( dropDownFired ) { // What you need to do here is make an AJAX call to a php (or other) script to get // back the required data and once you have that data show the second drop down // box and so on ect... } </script> <!-- Drop Down 1 --> <select name="dd1" onchange="fire_ajax('1')"> <option value="1">1</option> </select> <select name="dd2" onchange="fire_ajax('2')" style="display:none;"> <option value="1">1</option> </select> Sorry thats not a 100% answer but there is a bit of work required (maybe 30 mins or so) to write up everything and test it, ect... Basically what you'll want to do in your Javascript is make an AJAX call to get back the data, then use Javascript to change the css display of the second drop down to "Block" and then use Javascript to dynamically fill in the values of that drop down list. This is done much easier when using a Javascript library like jQuery. Quote Link to comment https://forums.phpfreaks.com/topic/183882-three-dependent-drop-down-boxes-with-data-from-mysql-database/#findComment-970838 Share on other sites More sharing options...
MadTechie Posted December 3, 2009 Share Posted December 3, 2009 May help Dynamic DropDown PHP/AJAX (its a bit dated now) Quote Link to comment https://forums.phpfreaks.com/topic/183882-three-dependent-drop-down-boxes-with-data-from-mysql-database/#findComment-970881 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.