Drop-down for country-states

与世无争的帅哥 提交于 2020-05-14 18:10:13

问题


Hi I want to implement a drop-down for countries and states.The states drop-down should change its values according to the country selected. Is there any plugin or gem to do this in rails.


回答1:


Try the Carmen plugin:

http://autonomousmachine.com/posts/2009/4/1/carmen-a-rails-plugin-for-geographic-names-and-abbreviations

You can also check this other stackoverflow post:

Ruby on Rails Country/State Select Enigma




回答2:


Country State Select is a library that provides an easy API to generate Country and State / Province dropdowns for use in forms.

When implemented correctly, a State / Province dropdown is filled with appropriate regions based on what Country a user has selected.

After it's version 2.0.0 it also dependent to simple_form 3.2

you can also find cities according to the state and country name by using this gem

https://rubygems.org/gems/country_state_select



来源:https://stackoverflow.com/questions/6825564/drop-down-for-country-states

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!