Verifying if radio buttons are checked

Hello,
I’ve 4 radio_buttons dynamically generated :
Code :
<% @collection.each do |q| %>

<%= q.value %>


<%= radio_button q.id.to_s, “choice”, “1” %>
q.choice1
<%#, :onclick => remote_function(:url => {:action => …%>
q.choice2
<%= radio_button q.id.to_s, “choice”, “2”%>
<%end%>

Everytime the user click on a radio_button, I wan’t to verify that all
others are checked and show a link to the next page. But I can’t verify
if all my radio_buttons are checked. I can only show the link if only
one radio is clicked.
Code :

[…],:onclick => remote_function(:url => {:action => “next”}) %>

in the controller
Code :

def next
render :update do |page|
page.replace_html “next”,link_to(“Next”,:action =>“next_page”)
end
end

thanks

you could put them all in a remote form and instead of calling the
remote_function in onclick submit that form. than you get them all in
your controller as params.

Thorsten M. wrote:

you could put them all in a remote form and instead of calling the
remote_function in onclick submit that form. than you get them all in
your controller as params.

Can you give me more details plz (a little example of code…)
Thanks

<%= form_remote_for(…) do |f| %>

you checkboxes go here like that:
<%= f.check_box “col_name_or_whatever”, :onchange =>
“$(‘your_form_id’).submit();” %>

<% end %>

in you controller you get all the form data as with any other form. make
sure, every checkbox get’s it’s own name/id

Thorsten M. wrote:

<%= form_remote_for(…) do |f| %>

you checkboxes go here like that:
<%= f.check_box “col_name_or_whatever”, :onchange =>
“$(‘your_form_id’).submit();” %>

<% end %>

in you controller you get all the form data as with any other form. make
sure, every checkbox get’s it’s own name/id

I’ve written this code
<% remote_form_for :check_boxes, “check_boxes”, :url => { :action =>
“validate”}, :html => { :id => “check_boxes” } do |f| %>

<%= radio_button q.id.to_s, "choice", "1", :onclick => "$('check_boxes').submit();", :current_page => @pager.current_page%>

but when I click on the radio_button, I’ve the next error :
try {
Element.update(“next”, “\u003Ca
href=”/questionnaires/list_questions?page=1"\u003ENext\u003C/a\u003E");
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());
alert(‘Element.update(“next”, “\u003Ca
href=\”\/questionnaires\/list_questions?page=1\"\u003ENext\u003C\/a\u003E");’);
throw e }

What does it mean?

your response:

page.replace_html “next”,link_to(“Next”,:action =>“next_page”)

seems to generate an error (so at least clicking the checkbox seems to
submit the form and call the action)
as far as i can see, it tries to render the ajax response as normal html
or text

(was this rendered as content of the page or an actual error message by
the browser?)