Hi All
I have four radio buttons created like this
<%= radio_button_tag :answers, 1, false %> a <br/>
<%= radio_button_tag :answers, 2, false %> b <br/>
<%= radio_button_tag :answers, 3, false %> c <br/>
<%= radio_button_tag :answers, 4, false %> d <br/>
And then I have a link_to tag to invoke a controller function
<%= link_to ''Next'', :action => :conduct %>
The issue is I want to pass the selected radio button value to this
function. Does anyone know how can I get the selected value?
Thanks for the help
- AJ
--
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
-~----------~----~----~----~------~----~------~--~---
On 2008-08-21 04:49, Abhishek Jain wrote:> I have four radio buttons created like this > > <%= radio_button_tag :answers, 1, false %> a <br/> > <%= radio_button_tag :answers, 2, false %> b <br/> > <%= radio_button_tag :answers, 3, false %> c <br/> > <%= radio_button_tag :answers, 4, false %> d <br/> > > And then I have a link_to tag to invoke a controller function > > <%= link_to ''Next'', :action => :conduct %> > > The issue is I want to pass the selected radio button value to this > function. Does anyone know how can I get the selected value?params[:answers] -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
greg is right, however, you need to put the radio buttons in a form
like such:
<% form_tag ''url/of/controller/function'' do %>
<%= radio_button_tag :answers, 1, false %> a <br/>
<%= radio_button_tag :answers, 2, false %> b <br/>
<%= radio_button_tag :answers, 3, false %> c <br/>
<%= radio_button_tag :answers, 4, false %> d <br/>
<% end %>
then, in your controller, you can access the value selected via
params[:answers]
On Aug 21, 3:49 am, Abhishek Jain
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi All
>
> I have four radio buttons created like this
>
> <%= radio_button_tag :answers, 1, false %> a <br/>
> <%= radio_button_tag :answers, 2, false %> b <br/>
> <%= radio_button_tag :answers, 3, false %> c <br/>
> <%= radio_button_tag :answers, 4, false %> d <br/>
>
> And then I have a link_to tag to invoke a controller function
>
> <%= link_to ''Next'', :action => :conduct
%>
>
> The issue is I want to pass the selected radio button value to this
> function. Does anyone know how can I get the selected value?
>
> Thanks for the help
> - AJ
> --
> Posted viahttp://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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
forgot one important thing. your link_to is only a link, it will NOT
populate params and will NOT care about your radio buttons.
the link you need for this is a submit button in your form:
<% form_tag :action => ''conduct'' do %>
<%= radio_button_tag :answers, 1, false %> a <br/>
<%= radio_button_tag :answers, 2, false %> b <br/>
<%= radio_button_tag :answers, 3, false %> c <br/>
<%= radio_button_tag :answers, 4, false %> d <br/>
<%= submit_tag ''Next'' %> # !!!!! IMPORTANT
<% end %>
On Aug 21, 11:12 am, "\"Wolas!\""
<jcpen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> greg is right, however, you need to put the radio buttons in a form
> like such:
>
> <% form_tag ''url/of/controller/function'' do %>
>
> <%= radio_button_tag :answers, 1, false %> a <br/>
> <%= radio_button_tag :answers, 2, false %> b <br/>
> <%= radio_button_tag :answers, 3, false %> c <br/>
> <%= radio_button_tag :answers, 4, false %> d <br/>
>
> <% end %>
>
> then, in your controller, you can access the value selected via
> params[:answers]
>
> On Aug 21, 3:49 am, Abhishek Jain
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
> wrote:
>
> > Hi All
>
> > I have four radio buttons created like this
>
> > <%= radio_button_tag :answers, 1, false %> a <br/>
> > <%= radio_button_tag :answers, 2, false %> b <br/>
> > <%= radio_button_tag :answers, 3, false %> c <br/>
> > <%= radio_button_tag :answers, 4, false %> d <br/>
>
> > And then I have a link_to tag to invoke a controller function
>
> > <%= link_to ''Next'', :action =>
:conduct %>
>
> > The issue is I want to pass the selected radio button value to this
> > function. Does anyone know how can I get the selected value?
>
> > Thanks for the help
> > - AJ
> > --
> > Posted viahttp://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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
"Wolas!" wrote:> forgot one important thing. your link_to is only a link, it will NOT > populate params and will NOT care about your radio buttons. > > the link you need for this is a submit button in your form: > > <% form_tag :action => ''conduct'' do %> > > <%= radio_button_tag :answers, 1, false %> a <br/> > <%= radio_button_tag :answers, 2, false %> b <br/> > <%= radio_button_tag :answers, 3, false %> c <br/> > <%= radio_button_tag :answers, 4, false %> d <br/> > > <%= submit_tag ''Next'' %> # !!!!! IMPORTANT > <% end %>Thanks for the help guys, I will try that out - AJ -- 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 -~----------~----~----~----~------~----~------~--~---