World Countries and State List
Compiled by Tim Davis, this snippet contains dropdown lookups of the world ISO countries and states.
Tim Davis (www.timdavis.com.au) has compiled a list of the ISO countries and their corresponding states. Within this list, countries are categorized by their Alpha 2 country code (i.e. "US"), their Alpha 3 country code (i.e. "USA") and their full ISO name (i.e. "United States"). This Toolbox Snippet uses this information in dropdown lists, illustrating how you can use dropdown lists to choose state and country information. Furthermore, this example limits the state options available depending on which country is selected.
This Toolbox Snippet utilizes a stored script file called "ISO_Countries.js" that contains the source listing of countries and states. In its entirety, these lists are quite large - totally over 200 different countries and thousands of states. To make these lists more manageable, this stored script file has been engineered to allow for both a default country value and a short list of country values.
For example, if the majority of your work is done for companies within the US, you may elect to set "US", "USA", and "UNITED STATES" as the default values. You may also elect to set the United States, Canada, and Mexico as countries to appear in the short list if a majority of your work is done within North America. Alternatively, you may also elect to simply get a listing of all countries.
The following functions are defined within the script file, which may be called from a dropdown on the form:
- ISO_Countries.Alpha2( true ) - retrieves the full list of countries using the Alpha 2 codes (AD, AE, AF, etc.)
- ISO_Countries.Alpha2( ) - retrieves the short list of countries using the Alpha 2 codes (US, CA, MX, etc.)
- ISO_Countries.Alpha3( true ) - retrieves the full list of countries using the Alpha 3 codes (AND, ARE, AFG, etc.)
- ISO_Countries.Alpha3( ) - retrieves the short list of countries using the Alpha 3 codes (USA, CAN, MEX, etc.)
- ISO_Countries.Name( true ) - retrieves the full list of countries using the country Name (ANDORRA, UNITED ARAB EMIRATES, AFGHANISTAN, etc.)
- ISO_Countries.Name( ) - retrieves the short list of countries using the country Name (UNITED STATES, CANADA, MEXICO, etc.)
- ISO_Countries.State( country ) - retrieves the list of states for the country specified
- Download and install a sample form illustrating this Toolbox Snippet (see below).
Country and State Data by Tim Davis is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Australia License.
Based on a work at www.timdavis.com.au.
Express permission has been sought and approved by MetaCommunications for use in our software. Further permissions beyond this scope are available at www.timdavis.com.au.