【发布时间】:2011-12-13 03:39:55
【问题描述】:
Rails 菜鸟在这里提出问题。
我正在尝试让用户输入他们的电话号码。表单目前包含国家代码、区号和电话号码的单独字段。
<% form_tag phones_path, :method => 'get' do %>
<th><%= text_field_tag :countrycode %></th>
<th><%= text_field_tag :areacode %></th>
<th><%= text_field_tag :search, params[:search] %></th>
<th><%= submit_tag "Search", :name => nil %></th>
<% end %>
我想将 countrycode 字段转换为国家名称的下拉选择,并在选择时自动显示实际的国家代码。例如,用户选择 USA,并显示 +1。我将存储国家名称和数字代码。
我想我需要结合使用collection_select 下拉菜单和javascript 来刷新显示。但我对如何进行有点迷茫。请好心人给点提示好吗?
【问题讨论】:
标签: javascript ruby-on-rails drop-down-menu