check_box and rjs

Hi, In my view I currently have the following link which show/hides a div       <%= link_to_function "Show Hide" do |page|         page[:user_input_name].toggle       end %>

Instead of using a link to do the show/hiding I would like to use the onclick event of a checkbox. I understand that I can add javascript to the onclick event as follows:    <%= form.check_box :io_1 ,{:onclick => "alert('Testing');"}%>

However, is it possible to use rjs code in the onclick part of the form.check_box? I know that i can look at the view and grab the javascript generated by the link and explicitly paste that into the onclick part but I like using the RJS syntax. Is it possible? e.g. something like:    <%= form.check_box :io_1 ,{:onclick => do |page| page[:user_input_name].toggle end }%>

Thanks

That's basically what update_page does. The name is a bit misleading, but basically it yields the same thing as you get in a render :update or the magic page object in a rjs file and returns the generated javascript.

Fred

sorry, so how do I use updaet_page in conjuction with a checkbox? The following doesn't work: <%= form.check_box :io_1 , update_page{|page| page[:user_input_name].toggle}%>

Apologies, I was being stupid. The correct way is:       <%= form.check_box :io_1 , :onclick => update_page{|page| page[:user_input_name].toggle}%>

Thanks for your help