title: drop down country selection for phone country code in rails
body: <p>Rails noob here posing a question.</p>
  
  <p>I'm trying to get users to input their phone number. Form contains separate fields for countrycode, areacode and phonenumber at the moment.</p>
  
  <pre><code>&lt;% form_tag phones_path, :method =&gt; 'get' do %&gt;
  &lt;th&gt;&lt;%= text_field_tag :countrycode %&gt;&lt;/th&gt;
  &lt;th&gt;&lt;%= text_field_tag :areacode %&gt;&lt;/th&gt;
  &lt;th&gt;&lt;%= text_field_tag :search, params[:search] %&gt;&lt;/th&gt;
  &lt;th&gt;&lt;%= submit_tag "Search", :name =&gt; nil %&gt;&lt;/th&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I want to convert the countrycode field into a dropdown selection of country names, and automatically display the actual country code upon selection. Eg user selections USA, and +1 is displayed. I am going to store both the country name and the numerical code.</p>
  
  <p>I think I need to use a combination of collection_select for the dropdown and javascript to refresh the display. But I'm kinda lost as to how to proceed. Will any kind soul give some hints please?</p>