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 <select name="bookID"> ... </select> .... <td><%=link_to ''Bai 2'', :action=>''b2'',:id=>..help me ... %></td> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
bala kishore pulicherla
2007-Mar-01 09:29 UTC
Re: how to get value from select box in rhtml page
I Hope it will work for you, <%= link_to "Bai 2", :controller => ''Your_controller'', :action => ''your_action'', :id => @params[''bookID''] %> On 3/1/07, Thuy Tien <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > 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 > > <select name="bookID"> > ... > </select> > .... > <td><%=link_to ''Bai 2'', :action=>''b2'',:id=>..help me ... %></td> > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 workSorry 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---