Skip to content

Instantly share code, notes, and snippets.

@d33pfri3d
Created August 25, 2012 19:44
Show Gist options
  • Save d33pfri3d/3470105 to your computer and use it in GitHub Desktop.
Save d33pfri3d/3470105 to your computer and use it in GitHub Desktop.
Datalist of US States
<datalist id="statelist">
<option value="Alabama"></option>
<option value="Alaska"></option>
<option value="Arizona"></option>
<option value="Arkansas"></option>
<option value="California"></option>
<option value="Colorado"></option>
<option value="Connecticut"></option>
<option value="Delaware"></option>
<option value="District of Columbia"></option>
<option value="Florida"></option>
<option value="Georgia"></option>
<option value="Hawaii"></option>
<option value="Idaho"></option>
<option value="Illinois"></option>
<option value="Indiana"></option>
<option value="Iowa"></option>
<option value="Kansas"></option>
<option value="Kentucky"></option>
<option value="Louisiana"></option>
<option value="Maine"></option>
<option value="Maryland"></option>
<option value="Massachusetts"></option>
<option value="Michigan"></option>
<option value="Minnesota"></option>
<option value="Mississippi"></option>
<option value="Missouri"></option>
<option value="Montana"></option>
<option value="Nebraska"></option>
<option value="Nevada"></option>
<option value="New Hampshire"></option>
<option value="New Jersey"></option>
<option value="New Mexico"></option>
<option value="New York"></option>
<option value="North Carolina"></option>
<option value="North Dakota"></option>
<option value="Ohio"></option>
<option value="Oklahoma"></option>
<option value="Oregon"></option>
<option value="Pennsylvania"></option>
<option value="Rhode Island"></option>
<option value="South Carolina"></option>
<option value="South Dakota"></option>
<option value="Tennessee"></option>
<option value="Texas"></option>
<option value="Utah"></option>
<option value="Vermont"></option>
<option value="Virginia"></option>
<option value="Washington"></option>
<option value="West Virginia"></option>
<option value="Wisconsin"></option>
<option value="Wyoming"></option>
</datalist>
@MrGrigri
Copy link

MrGrigri commented Dec 2, 2019

I would include the two-character postal code for each state as the values and add the label attribute with the state's name as it's value like the following.

<datalist id="states">
  <option label="Alabama" value="al"></option>
  <option label="Alaska" value="ak"></option>
  <option label="Arizona" value="az"></option>
  ...
  <option label="West Virginia" value="wv"></option>
  <option label="Wisconsin" value="wi"></option>
  <option label="Wyoming" value="wy"></option>
</datalist>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment