Weiss Posted August 31, 2017 Share Posted August 31, 2017 Hi all. Soo.. im creating this form where one of the fields the user have to select his city.. i want him to select from a list with all the cities in our country, of cours we hace more than 1.5k cities.. i imagine theres a better way to handle this other than go city after city inside <option>.. right? Thanks in advance Link to comment Share on other sites More sharing options...
dsonesuk Posted August 31, 2017 Share Posted August 31, 2017 You could use optgroup tag to divide them in to states/county's, or have select states/county's, that will bring up dropdown of city's within that state/county only. Link to comment Share on other sites More sharing options...
Weiss Posted September 1, 2017 Author Share Posted September 1, 2017 I actually dont live in the U.S.. in here we just have country name and then city name Link to comment Share on other sites More sharing options...
dsonesuk Posted September 1, 2017 Share Posted September 1, 2017 So you think that only U.S has states? interesting Link to comment Share on other sites More sharing options...
Weiss Posted September 1, 2017 Author Share Posted September 1, 2017 Back to the topic, as mentioned i need to make a select list with 1.5k cities. Is there a quick way to do that? Link to comment Share on other sites More sharing options...
dsonesuk Posted September 1, 2017 Share Posted September 1, 2017 (edited) If you want to list altogether, Either list in JavaScript array, xml file, or server database, then loop through them producing the options within <select>...</select> elements. Edited September 1, 2017 by dsonesuk 1 Link to comment Share on other sites More sharing options...
sternco Posted September 27, 2017 Share Posted September 27, 2017 You could use some Excel formulae or VBA code to write all the <select>s for you, then just copy paste it into the form code. Still looks ugly, but by automating writing the code, you reduce the pain a lot. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now