dcay Posted February 14, 2007 Share Posted February 14, 2007 Hi there! My question is : can I use php to create 5 drop down boxes that "all" depend of each other ? here for example : http://www.e-wohnungsmarkt.at . How can I make all the location select (from country to locals) interact with each other ? If I chose zip - the selectet values to be the country where the zip is - the distrcit location - city asociacted with that zip... Cristi. Link to comment https://forums.phpfreaks.com/topic/38467-selects-box-drop-down-that-depend-on-each-other/ Share on other sites More sharing options...
mbtaylor Posted February 14, 2007 Share Posted February 14, 2007 How I usually do that is use a bit of javascript on the select tag to submit the form like: <form name='myform'> <select name='something' onchange='document.forms.myform.submit()'> <option>Moo</option> </select> </form> Then look for the post variable 'something' and if it exists, you can use it to populate the db query that populates the next select element. Make sense? Link to comment https://forums.phpfreaks.com/topic/38467-selects-box-drop-down-that-depend-on-each-other/#findComment-184550 Share on other sites More sharing options...
dcay Posted February 14, 2007 Author Share Posted February 14, 2007 yes, I do eaxactly the same thing but I want to do something else . let's say I have the fields - country - district- city - zip. for now my script works like you say . if I select a country - in the district field I get the districts in that country. what I want to do is : the selects all have the default string value "All" (option value="0") . I want that when I select zip - country , district , city to be populated with the corresponding values. the country where the zip is from , the district and the city. If I select district - the same thing - the selected values form the other boxes to change to country where the zip is from, the cities& zips in that district. does it make sense? I want that all the selects depend on each other. Link to comment https://forums.phpfreaks.com/topic/38467-selects-box-drop-down-that-depend-on-each-other/#findComment-184557 Share on other sites More sharing options...
mbtaylor Posted February 14, 2007 Share Posted February 14, 2007 Im not quite sure what you mean, are you wanting to do address lookups by zip code? If so there are services that can do that. Or are you wanting to just select the appropriate option that relates? If so then I would look at the vars being posted and compare with the current value in the loop like: $selected = $db_countryID == $countryID ? " selected" : ""; print "<option value='$db_countryID'$selected>$country_name</option>"; You might need to use some hidden form fields maybe... not knowing what you are doing exactly. Link to comment https://forums.phpfreaks.com/topic/38467-selects-box-drop-down-that-depend-on-each-other/#findComment-184594 Share on other sites More sharing options...
boo_lolly Posted February 14, 2007 Share Posted February 14, 2007 post some code with a detailed description of where you are at, and where you want to go. Link to comment https://forums.phpfreaks.com/topic/38467-selects-box-drop-down-that-depend-on-each-other/#findComment-184602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.