Welcome to WebmasterWorld Guest from 54.159.50.111

Forum Moderators: phranque

Message Too Old, No Replies

How to populate the city state field based on zip code

     
1:50 am on Apr 14, 2010 (gmt 0)

New User

5+ Year Member

joined:Apr 14, 2010
posts: 6
votes: 0


I'm trying to find out how to make teh city and state fields pre populate based off the zip code a user enters.

Can you point me in the right direction?

Thanks,

Jay
8:10 am on Apr 14, 2010 (gmt 0)

Administrator from JP 

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month Best Post Of The Month

joined:Oct 12, 2000
posts:14483
votes: 49


Welcome to WebmasterWorld Jay Wilson Jr.

Most ZIP code databases include that information. Do you have a ZIP code database to work with?

Then it would depend on what type of technology you were using for your site.
8:21 am on Apr 14, 2010 (gmt 0)

New User

5+ Year Member

joined:Apr 14, 2010
posts: 6
votes: 0


Thank you for the welcome...

No I do not have a database. Can you recommend one?

Thanks,

Jay
4:15 am on Apr 15, 2010 (gmt 0)

Administrator from JP 

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month Best Post Of The Month

joined:Oct 12, 2000
posts:14483
votes: 49


I believe the US Post Office offers them.
10:28 pm on Apr 15, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 22, 2005
posts:1152
votes: 4


This is going to take some programming, of course. And it might not be worth it.

Also, think about this...

You know how you ask people twice to enter say, their password? People get it wrong. It's a good check to ask for this backup.

Even if you're not mailing them anything, but building a db, it's a good check to enhance the info's accuracy.

Now, if you are going to be mailing people stuff, you need to check out the USPS database where they'll make labels for you and such. A better investment would be to create an interface with their program.

Drill down deep into the postal service's web site for businesses that mail. And, of course, check out the other shippers web sites as well.
5:21 am on Apr 16, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 0


USPS does offer their raw database on CD at a cost. I think $1,000 a year, but I'm not sure about that. You'd need to be able to convert it to SQL or something, and if you're good with databases it's fun and powerful to work with. It will let you convert zip codes to cities and vice-versa, and validate complete addresses down to the apartment number and Zip+4.
5:47 am on Apr 16, 2010 (gmt 0)

New User

5+ Year Member

joined:Apr 14, 2010
posts: 6
votes: 0


Thank you guys for the great input!

I have this working now. The USPS zip database is a great resource. Thanks for pointing me towards it.


Jay
1:46 pm on Apr 17, 2010 (gmt 0)

Full Member

5+ Year Member

joined:May 3, 2006
posts:263
votes: 0


I thought zip codes were public domain in the USA?

(In the UK the Royal Mail holds ownership of them.)
4:46 pm on Apr 17, 2010 (gmt 0)

New User

5+ Year Member

joined:Apr 14, 2010
posts: 6
votes: 0


In doing my research I found lots of Free zip databases....

I also found some paid databases as well. It would be my guess that the database complied by the USPS would be most accurate, I am not sure if zips are public domain or not...

If they are then, of course anyone could package them up and sell them under certain guidelines.


Jay
4:51 pm on Apr 17, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 27, 2003
posts:732
votes: 0


Be aware that some towns share a zip code. The wrong town name may come up.
4:54 pm on Apr 17, 2010 (gmt 0)

New User

5+ Year Member

joined:Apr 14, 2010
posts: 6
votes: 0


I noticed that...

I made it so that the field is editable, so the user can change it if need be. I am not shipping anything to the address at this time. If it ends up being a issue I will remove the autofill...

I am hoping my having it my cart abandon rate will lower.

Jay
4:56 pm on Apr 17, 2010 (gmt 0)

Senior Member

joined:Jan 3, 2003
posts:1023
votes: 0


zip codes used to be a service mark. they are not "public domain", they are an identification of a private corporation and are OPTIONAL in the united states: see Domestic Mail Services Regulations, Section 122.32. They should only apply to the places that fall under the jurisdiction of the District of Columbia.

As far as my limited knowledge of the subject goes, US has 2 separate laws, and 2 separate jurisdictions - State and Federal. There are people who fall under one and not under the other. People who do not fall under the "Federal" commercial law, will use addresses without a zip code.

A Postal Service is "quasi-government" agency, i.e. a private corporation, just like Federal Reserve. Zip Code™ does not apply to addresses that fall under the jurisdiction of a State only - as in 50 states of the union, excluding District Columbia, Puerto Rico, Guam and a couple of other territories.
10:54 pm on Apr 17, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Apr 12, 2006
posts:290
votes: 0


I suggest being careful about using free zipcode databases, since ZIP codes *do* change over time - using free ones may open you up to stale/incorrect data.
4:19 pm on Apr 18, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 20, 2004
posts:2377
votes: 0


Just my 2 cents, but when I abandon a cart, it is not because I have to type in my state and city. It is usually because I have cold feet about spending the money, or I discover shipping costs are too high, or I decide to shop around for a better price.

I applaud you efforts to make the process more seamless, but I think you should also examine some other areas if you are having cart abandonment issues.
5:07 pm on Apr 18, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member netmeg is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 30, 2005
posts:12677
votes: 143


I use one for my events sites, but I run into problems because physical addresses aren't necessarily the same as mailing addresses. Thinking of unhooking it.

I agree with maximillianos though - I don't think it will likely do too much to improve your cart issues. In my experience, shipping costs and lack of a "one button" order process contribute the most.
6:55 pm on Apr 18, 2010 (gmt 0)

New User

5+ Year Member

joined:Apr 14, 2010
posts:6
votes: 0


You may be right - we are split testing this order form against the control. In a few days we will have some solid metrics.

Thanks for the great feedback,

Jay
1:51 am on Apr 19, 2010 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14624
votes: 88


You can find lots of free zip code databases, just look around, it's all there for free.

If you don't know much about databases and you only use this database like once per member, so it's not getting hit alot, it requires almost NO programming to get the data you need almost instantly.

Forget importing to a database and all that mess, download a CSV or fixed width record format file and access it redneck programmer style.

You can execute a shell command to "GREP" the raw data file and it spits out a record in a fraction of a second.

So something like this will get your data:


grep "95501" -i zipdatabase > temp0124


Read the content of temp0124 for the results.
2:30 pm on Apr 19, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 30, 2005
posts:56
votes: 0


Its all done for you!

I would go for geocode services

[geonames.org...]

Cheers