Welcome Guest, Not a member yet? Register   Sign In
Sorting results into categories for Select dropdown
#1

[eluser]Andy UK[/eluser]
Good evening all,

I currently have a dropdown select with cities in alphabetical order. Some are from one country and some are from another. I would now like to separate these cities into categories, the category being the country.

With a simple activerecord join I can add the country name to the result set for each city, but I don't know if there's a way to use this to categorise the results. Is this possible or will I have to first loop through the countries and query the database for each country to get the active cities and then store in a multiple array by country? I'm guessing the second, but if anyone knows an easier way, I'm interested in hearing it!

Thanks
#2

[eluser]CroNiX[/eluser]
If you have a lot of options it might be better to separate it into 2 dropdown. When the first dropdown (country) is selected, it populates the 2nd dropdown with the cities from that country.




Theme © iAndrew 2016 - Forum software by © MyBB