Skip to content

This is a small JS file to use country select box according to a continent select previously.

License

Notifications You must be signed in to change notification settings

codelandev/continent-country

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Continent Country select (demo page)

What is it?

This is a small JavaScript file which can transform a select box in a country selector field accordly to the continent selected, very similar to the cidades-estados javascript file (actually, this is a fork) of that file.

How to use this?

In order to use this plugin, you need to add the following above:

Copy the main file inside your project and require this

Put Simple Form (or whatever) input on your view

= f.input :continent, required: true
= f.input :country, as: :string, required: true

NOTE: See this as: :string up? this is to resolve conflicts with country_select gem.

With jQuery

<script type="text/javascript">
$(function() {
  new dgContinentsCountries({
    continentVal: document.getElementById("[model]_continent").val,
    countryVal: document.getElementById("[model]_country").val,
    continent: document.getElementById("[model]_continent"),
    country: document.getElementById("[model]_country"),
    change: true
  });
});
</script>

With Prototype

<script type="text/javascript">
Event.observe(window, 'load', function() {
  new dgContinentsCountries({
    continent: $('[model]_continent'),
    country: $('[model]_country')
  });
});
<script>

It's simple!

Credits

The credits go mainly for the creators of the first plugin 'cidades-estados' Roberto && Michael

Extra

Need files with the name of all countries and their cities? Here we are!

About

This is a small JS file to use country select box according to a continent select previously.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •