# How to get value from select box in rhtml page

**URL:** <https://www.ruby-forum.com/t/how-to-get-value-from-select-box-in-rhtml-page/87250>\
**Category:** Rails\
**Created:** [March 1, 2007, 7:11am UTC](https://www.ruby-forum.com/t/how-to-get-value-from-select-box-in-rhtml-page/87250 "2007-03-01T07:11:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trai\_dau\_bap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@trai\_dau\_bap](https://www.ruby-forum.com/u/trai_dau_bap)\
**Post date:** [March 1, 2007, 7:11am UTC](https://www.ruby-forum.com/t/how-to-get-value-from-select-box-in-rhtml-page/87250/1 "2007-03-01T07:11:07Z")

</div>

I have an select box in my rhtml page and I wanna put a link on the  
buttom of this page .when user choose to link to another page i wanna  
get the selected value that user has chosen in the select box and send  
it to another rhtml page by the variable named :id. please show me how  
to get a value from a tag in rhtml pages right on this page

... .... \<%=link\_to 'Bai 2', :action=\>'b2',:id=\>..help me ... %\>

---

<div class="post-metadata">

**Author:** ![trai\_dau\_bap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@trai\_dau\_bap](https://www.ruby-forum.com/u/trai_dau_bap)\
**Post date:** [March 1, 2007, 10:29am UTC](https://www.ruby-forum.com/t/how-to-get-value-from-select-box-in-rhtml-page/87250/2 "2007-03-01T10:29:47Z")

</div>

I Hope it will work for you,

\<%= link\_to “Bai 2”, :controller =\> ‘Your\_controller’, :action =\>  
‘your\_action’, :id =\> @params[‘bookID’] %\>

---

<div class="post-metadata">

**Author:** ![trai\_dau\_bap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@trai\_dau\_bap](https://www.ruby-forum.com/u/trai_dau_bap)\
**Post date:** [March 1, 2007, 2:39pm UTC](https://www.ruby-forum.com/t/how-to-get-value-from-select-box-in-rhtml-page/87250/3 "2007-03-01T14:39:31Z")

</div>

Hi Thuy,

Thuy Tien wrote:

> when i get value of id from controller pages by params[:id]  
> it return the nil value. maybe @params[] just can work in  
> controller pages so when we put it in rhtml pages it can’t work

Sorry I didn’t spot this earlier, but yes. The params[] hash is how  
information is passed from the client browser to the server. It is  
constructed and populated by the browser to send a request to the  
server. In  
Rails, requests are handled by invoking a method in a controller.  
Instance  
variables (e.g. @some\_name) are the mechanism in Rails for passing  
values  
from the controller to the view (i.e., the rhtml pages) that Rails is  
using  
to construct the page that will supply the response to the browser’s  
request.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![trai\_dau\_bap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@trai\_dau\_bap](https://www.ruby-forum.com/u/trai_dau_bap)\
**Post date:** [March 1, 2007, 2:21pm UTC](https://www.ruby-forum.com/t/how-to-get-value-from-select-box-in-rhtml-page/87250/4 "2007-03-01T14:21:26Z")

</div>

thanks bala kishore pulicherla for helping me but when i get value of id  
from controller pages by params[:id] it return the nil value. maybe  
@params[] just can work in controller pages so when we put it in rhtml  
pages it can’t work
