jasonhinkle / jquery-country-select

jQuery Country Selector Plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery Country Select

jQuery Country Select is a "Country Picker/Chooser" plugin for jQuery which populates a select drop-down with all available countries and ensures that the correct value is selected.

The plugin populates the drop-down without making any style changes, making it compatible with most any UI style kit.

Getting Started

Clone the repository or simply download the minified version or the development version.

Include the following on your web page. This example uses the id "country" for the select input, however you can use any id that you choose.

<!-- specify the selected value using the 'data-selected-value' attrib -->
<select id="country" data-selected-value="US"></select>

<script src="path/to/jquery.js"></script>
<script src="path/to/jquery.country.select.min.js"></script>
<script>
$(document).ready(function(){
    
  // initialize the country drop-down
  $('#country').countrySelect();
             
});
</script>

Documentation

When initializing the country selector, you can override the default options by passing an object with any/all of the following values:

var options = {
  showFullName: true,
  showEmptyValue: true,
  emptyValueLabel: 'Select Country...',
  countries: {US: 'United States', CA: 'Canada'}
};
             
$('#country').countrySelect(options);

Release History

  • 0.1.0 Initial Release

About

jQuery Country Selector Plugin

License:MIT License


Languages

Language:JavaScript 93.4%Language:CSS 5.8%Language:HTML 0.8%