How to display the selected values from the drop down list menu in rails?

16 views
Skip to first unread message

yash shah

unread,
Jul 28, 2013, 2:38:14 PM7/28/13
to rubyonra...@googlegroups.com
Dear Guys,
I have created the drop down list for state and city. Now when the user selects the state say florida and city say miami, I want to display these names on the new page when the user clicks the search link. Using link_to,  I am not able to pass these names to the new page. Ideally these selected names should go as :paramsbut they arent going through the url .Please me know if its still not clear. Thanks a lot!! Heres the code:

<%= form_for Investopp.new do |f| %>
<div class="field">
<%= f.label :state_id %><br/>
<%= f.collection_select  :state_id, Investopp.year_lookup(@state_ids), :label, :value, include_blank: true %>
</div>

<div class="field">
<%= f.label :city_id, "city" %><br />
<%= f.grouped_collection_select :city_id, Investopp.year_lookup(@state_ids), :cities, :value, :id,:name, include_blank: true %>
</div>
<% end %>
<%= link_to 'Back', investopps_path %>
<%= link_to 'Search', investopps_browsedisplay_path %>


Hassan Schroeder

unread,
Jul 28, 2013, 5:15:37 PM7/28/13
to rubyonra...@googlegroups.com
On Sun, Jul 28, 2013 at 11:38 AM, yash shah <yashsh...@gmail.com> wrote:

> I have created the drop down list for state and city. Now when the user
> selects the state say florida and city say miami, I want to display these
> names on the new page when the user clicks the search link. Using link_to,
> I am not able to pass these names to the new page.

Correct, or at least not without JavaScript.

The easiest way is to make 'Search' a submit button inside the form.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Reply all
Reply to author
Forward
0 new messages