# Submit a form

**URL:** <https://www.ruby-forum.com/t/submit-a-form/76412>\
**Category:** Rails\
**Created:** [November 18, 2006, 5:09pm UTC](https://www.ruby-forum.com/t/submit-a-form/76412 "2006-11-18T17:09:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pingu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9a28c/32.png) [@pingu](https://www.ruby-forum.com/u/pingu)\
**Post date:** [November 18, 2006, 5:09pm UTC](https://www.ruby-forum.com/t/submit-a-form/76412/1 "2006-11-18T17:09:27Z")

</div>

Hi everyone, i have the following code:

\<%= form\_tag :action =\> ‘list\_wedding\_by\_continent’, :id =\> “Africa” %\>  
\<%= collection\_select(:thing, :continent, @continent,“id”,“continent”)  
%\>  
\<%= submit\_tag ‘Search’ %\>  
\<%= end\_form\_tag %\>

how do i pass in the selected country in the list, instead of hard  
coding “Africa”  
thank you

---

<div class="post-metadata">

**Author:** ![pingu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9a28c/32.png) [@pingu](https://www.ruby-forum.com/u/pingu)\
**Post date:** [November 18, 2006, 9:31pm UTC](https://www.ruby-forum.com/t/submit-a-form/76412/2 "2006-11-18T21:31:45Z")

</div>

can anyone help me?

---

<div class="post-metadata">

**Author:** ![pingu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9a28c/32.png) [@pingu](https://www.ruby-forum.com/u/pingu)\
**Post date:** [November 19, 2006, 12:55am UTC](https://www.ruby-forum.com/t/submit-a-form/76412/3 "2006-11-19T00:55:42Z")

</div>

pingu wrote:

> thank you

Forget the rails helpers for a moment and go back to HTML basics.

You’ve got a form (which rails can help you create using form\_tag, or  
even better, form\_for). This submits a post request to a URL (which in  
the rails helper can be generated with a hash of parameters, including  
perhaps :action =\> ‘some\_action’). The contents of that form (including,  
as in your case, a select box, which rails can help you create with  
select, select\_tag, collection\_select, etc) are passed to the receiving  
URL for it to do with what it wants.

There’s no way (short of some javascript) that the chosen option of the  
select box can end up the url the form is submitting to, which I think  
is what you’re asking. Have a play around with the helpers and examine  
the source code they produce in your browser, or check out the API. It  
will all become clear… eventually.

---

<div class="post-metadata">

**Author:** ![pingu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9a28c/32.png) [@pingu](https://www.ruby-forum.com/u/pingu)\
**Post date:** [November 19, 2006, 9:51am UTC](https://www.ruby-forum.com/t/submit-a-form/76412/4 "2006-11-19T09:51:32Z")

</div>

Thanks Chris T, and i really appreciate you taking the time to explain  
it to me. But i am still confused, if there is no way to get the  
information out of a form, whats the point of it?

---

<div class="post-metadata">

**Author:** ![pingu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9a28c/32.png) [@pingu](https://www.ruby-forum.com/u/pingu)\
**Post date:** [November 19, 2006, 11:46am UTC](https://www.ruby-forum.com/t/submit-a-form/76412/5 "2006-11-19T11:46:00Z")

</div>

You should get the selected continent coming through as things are (just  
inspect the contents of the params hash that is passed to your  
controller.  
However I think you’re expecting params[:id] to contain the selected  
continent

This won’t happen because

- I think that having :id =\> ‘Africa’ in form\_tag will effectively mean  
that it’s overriden
- collection\_select (like the various other helpers of its family) will  
put the selected parameter in params[:thing][:continent] (Check out the  
html that is generated by your form

Fred

---

<div class="post-metadata">

**Author:** ![pingu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9a28c/32.png) [@pingu](https://www.ruby-forum.com/u/pingu)\
**Post date:** [November 19, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/submit-a-form/76412/6 "2006-11-19T19:35:53Z")

</div>

Great, thanks Fred - sorted it.
