Ajax, checkbox


#1

Hi,

I’d like to have a list of things with checkboxes in front of each. When
(un)checking the checkbox, a method should be invoked and I’d like to be
able to see a) which checkbox has been changed (best would be a numeric
id) and b) if the checkbox is now on or off.

This is my attempt

<%= start_form_tag({:action => “save”}, :id=>“checkform” ) %>
<%= check_box “checker”, “yesno”, :id => “boxx” %>
<%= submit_tag “save” %>
<%= end_form_tag %>

<%= observe_form “checkform”,
:frequency => 1,
:url => { :action => “save” },
:with => “sometext=value”
%>

When I uncheck the checkbox, the action ‘save’ is invoked and the
parameters look like this:

{“commit”=>“save”, “checker”=>{“yesno”=>“0”}, “action”=>“save”,
“controller”=>“check”}

(and “yesno” => “1” when checked).

Question: how do I get the id into the parameter list? Would this be the
only way:?

<%= check_box “checker[]”, “yesno”, :id => “boxx” %>

without the strange line “:with => ‘sometext=value’”, I won’t get any
useful results, why?

(Parameters: {“action”=>“save”, “controller”=>“check”})

How should I use the observe_form correctly?

Patrick


#2

Try posting your question on refwell.com. You might get your answer
there
James

On Feb 4, 11:33 pm, Patrick G. <rails-mailing-l…@andreas-