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

**URL:** <https://www.ruby-forum.com/t/how-to-display-the-selected-values-from-the-drop-down-list-menu-in-rails/235987>\
**Category:** Rails\
**Created:** [July 28, 2013, 8:39pm UTC](https://www.ruby-forum.com/t/how-to-display-the-selected-values-from-the-drop-down-list-menu-in-rails/235987 "2013-07-28T20:39:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [July 28, 2013, 8:39pm UTC](https://www.ruby-forum.com/t/how-to-display-the-selected-values-from-the-drop-down-list-menu-in-rails/235987/1 "2013-07-28T20:39:56Z")

</div>

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| %\>

\<%= f.label  
:state\_id %\>  
\<%= f.collection\_select :state\_id,  
Investopp.year\_lookup(@state\_ids), :label, :value, include\_blank: true  
%\>

\<%= f.label :city\_id, "city" %\>  
\<%= f.grouped\_collection\_select :city\_id, Investopp.year\_lookup(@state\_ids), :cities, :value, :id,:name, include\_blank: true %\>
\<% end %\>\<%= link\_to 'Back', investopps\_path %\>\<%= link\_to 'Search', investopps\_browsedisplay\_path %\>

---

<div class="post-metadata">

**Author:** ![yash\_shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bbce88/32.png) [@yash\_shah](https://www.ruby-forum.com/u/yash_shah)\
**Post date:** [July 28, 2013, 11:18pm UTC](https://www.ruby-forum.com/t/how-to-display-the-selected-values-from-the-drop-down-list-menu-in-rails/235987/2 "2013-07-28T23:18:14Z")

</div>

On Sun, Jul 28, 2013 at 11:38 AM, yash shah [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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 S. ------------------------ [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[Hassan Schroeder | about.me](http://about.me/hassanschroeder)  
twitter: @hassan
