radio_button_tag - examining the selected value

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

params[:answers]

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]

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

"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