felix_alves Posted January 11, 2007 Share Posted January 11, 2007 hi everyone. im having some trouble here.I have a php page with combo box with continents and a list of all countries after it. So far so good, but now i want to: when someone changes the combo box selected item lets say to Europe immediately the list after shows only countries in europe... (the countries and continents all come from a mysql database) how can i do it with php ? do i have to use ajax ?!Thanks in advance Link to comment https://forums.phpfreaks.com/topic/33784-listing-items-from-combo-box/ Share on other sites More sharing options...
emehrkay Posted January 11, 2007 Share Posted January 11, 2007 you have to use javascript or you can refresh the page (send it to the server to process) and use phpid go with plain javascript if your dropdowns wont be too big no need to ajax it. Link to comment https://forums.phpfreaks.com/topic/33784-listing-items-from-combo-box/#findComment-158427 Share on other sites More sharing options...
felix_alves Posted January 11, 2007 Author Share Posted January 11, 2007 thanks for fast reply,will try it. Link to comment https://forums.phpfreaks.com/topic/33784-listing-items-from-combo-box/#findComment-158429 Share on other sites More sharing options...
emehrkay Posted January 11, 2007 Share Posted January 11, 2007 here is an idea to get you started. on your continents drop down, give each option a unique value<select id = "continents"><option value ="Europe">Europe</option></select>then for your countries give each dropdown the id of the country it is for but name them all the same and use css to make them all hidden. display: none;<select id="Euorpe" name ="country"><option value ="spain">spain</option></select><select id="North America" name ="country"><option value ="canada">canada</option></select>now for your js create a function that will listen for a change in your continent dropdown and show the correct country dropdown. onload = function(){var cont = document.getElementById('continent');cont.onchange = function(){//call the function that will show/hide the country menu}} Link to comment https://forums.phpfreaks.com/topic/33784-listing-items-from-combo-box/#findComment-158437 Share on other sites More sharing options...
felix_alves Posted January 11, 2007 Author Share Posted January 11, 2007 the situation is slightly different and the continents/countries was just an example but with this last post i think i can make it now, thanks a lot for your time and very important help, if you wanna check the real situation of my problem go to www.actandfilm.com/headshot.php and change the combo box there...you will know perfectly what i need than :) once again thank you! Link to comment https://forums.phpfreaks.com/topic/33784-listing-items-from-combo-box/#findComment-158447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.