The post below has the right question, but I’m seeking an updated response for helping me do the same with AI. Has anyone achieved this? If so, how?
Prior Q&A:
Can we use zip codes to identify city/state location?
I have a list of countries in my app, but cities are too abundant to list. Anyone know if we can use zip code to identify city/state? All US…
You could probably create a JSON object, or some kind of delimited list of all city/state/zip combinations, pass that as input into a custom component, and have it generate a dropdown.
I’d like the user to put in a zip and it automagically generates/fills in the city and state fields. Do your guidance change at all, knowing this? Or is it the same?
What if your ZIP code isn’t unique across countries? Say I search for a random number like 4000, it shows me both Liège, Belgium and Brisbane, Australia.
Other experts will have more insight, but I believe the best approach for this would be to use an API to retrieve the City State based on the inputted Zip code.
Like ThinhDinh just mentioned, you need to consider localization.
It doesn’t change my suggestion. The main consideration is the size of the JSON data and keeping it up to date. There are several versions of some premade JSON out there if you do a search, but it may or may not fit into an entire cell. If I recall, a cell is limited to 1 million characters or something like that. Then you have to consider if you are doing it for other countries as well as the others have pointed out.
I think @Atom makes a good point though about using an API though. The results would always be current.
Just bouncing some ideas. This isn’t something i’ve attempted myself.