How to get value from select box in rhtml page

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

I Hope it will work for you,

<%= link_to “Bai 2”, :controller => ‘Your_controller’, :action =>
‘your_action’, :id => @params[‘bookID’] %>

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs