• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 63
  • Last Modified:

Zip to city state

Look for simple way to get city and state by provide zip code.
I have HTML form thanks
0
ITsolutionWizard
Asked:
ITsolutionWizard
1 Solution
 
Olaf DoschkeSoftware DeveloperCommented:
Google Geocoding API would help here.
Are you familiar with Javascript/jQuery, Ajax, API usage, XML/JSON?
Depending on that there's a steep learning curve ahead here.
I think you should know a bit of these and might suffice with the hint on the base address for the postal code request:
http://maps.googleapis.com/maps/api/geocode/json?address=<<zipcode here>>&key=<<Your Google API key here>>

Open in new window

Just as a starter, because that could lead you outside the USA easily, though Google will make the result depend on the location of the request, this could lead to wrong places for users searching US addresses with US zip codes. For example, I get German addresses.

Get a google account and api key here: https://developers.google.com/maps/documentation/javascript/get-api-key

Bye, Olaf.
1
 
Bill PrewCommented:
If you have a real business need then it might be worth it to subscribe / pay for a service that has solid availability and updated data, etc.

If you are just looking for a casual capability, here's a couple of potential references worth a look.



»bp
0
 
Jim RiddlesPrepress/OMS SpecialistCommented:
Possible duplicate of zip code to city list.

Bill already provided the same answer in that post.  Perhaps it would be better to stick to asking your question once.

That said, depending on your usage requirements, ZIP Code API offers a free account for up to 50 requests per hour, or you can sign up for a usage account, if you have greater needs.

ZIP Code API Examples
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
ITsolutionWizardAuthor Commented:
http://www.zippopotam.us/ is working me. But the State does not work to me - maybe because I use <select>
Let me know if you can help ....

Thank you for all your helps. You guys are awesome.

 <select tabindex="4"  style="text-transform:uppercase;" class="form-control" name="state" id="state">
0
 
Bill PrewCommented:
Can you share the rest of the related code, preferably in a sample web page?


»bp
0
 
Jim RiddlesPrepress/OMS SpecialistCommented:
I think the important question to ask yourself is why you are using a select input field if you are getting the data via and AJAX call based on the ZIP Code.  At that point, you are probably best served changing your State field to a text input field.

If you are forced to keep the select input control, then it is probably an issue with the JavaScript function.
0
 
Jim RiddlesPrepress/OMS SpecialistCommented:
Here's a JSFiddle showing their API in use with a select input for State.
https://jsfiddle.net/riddjim/h1fLvzjL/2/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now