US States list for CCK select boxes

Published August 22, 2008

When defining Content Types in Drupal with the Content Construction Kit you are able to add select boxes to them with CCK. It takes its
key/value pairs in this format: Key|Value. One of the most common tasks for this is to create a drop down list of US States. So to save folks some time, I have compiled a list for you to paste right into your own projects. The attached text file will give you US States in the expected format.

Hopefully this will save others a bit of typing when you need such a list for your own Drupal projects. Enjoy!

states.txt646 bytes

Comments

This is a convenient list, thanks! I hope that others will find it before building it themselves. In all the time and all the CCK forms I've built, I don't think I've actually built a list of states in the US.

I've shared a different kind list but for the same reason. It's a list of domains (for Drupal's 'access' table) to help prevent user accounts from using throwaway email addresses from services like Mailinator and Spam Gourmet.

I'm glad you found it useful. I was surprised not to see one out there, and after a little command line magic to format the list into the CCK style, I figured I'd post it out there to save some others the time.

And thanks for linking to your list, I've bookmarked it for future reference.

- Eric Marden

Submitted by Guest (not verified) on Tue, 08/26/2008 - 14:13

This just saved my butt again - not for CCK, but just because I remembered there was a list matching state shortcodes to state names.

The only one I got wrong was Nebraska (NE), other than that, I am 98% state-competent.

Submitted by admin on Fri, 02/13/2009 - 16:28

This is just what I was looking for but how does one get this into CCK and out again as a dropdown?

Submitted by Guest (not verified) on Thu, 02/26/2009 - 08:20

Hi 'Guest'

When creating a new field, you have the option of making it a select list. The text file is in the format that this field requires. Just paste it in and it will be populated correctly.

- Eric Marden

Submitted by Guest (not verified) on Thu, 02/26/2009 - 10:37

In reply to by Guest (not verified)

I am getting forbidden 403 page.

Please give the permission to download that file.

Submitted by venkat (not verified) on Sat, 01/21/2012 - 16:29

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!

Name
CAPTCHA