Forum: Ruby on Rails checkbox to toggle div

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4d47944ad8359101bccb0a798cd9acf1?d=identicon&s=25 Hugh (Guest)
on 2007-01-11 05:52
(Received via mailing list)
I'm trying to show a div if a checkbox is selected. I got as far as:

<%= check_box('foo','temporary_bar',{:onclick =>
"Element.toggle('temp_bar'); return false;"}, 1, nil)%>
<div id="temp_bar" style="display:none;">
 <%= text_field 'foo', 'temporary_bar_details' %>

The div toggles fine when clicking on the checkbox but it doesn't stay
checked. Any help is appreciated.

E1a469bab6c26730c324c3011e1993f0?d=identicon&s=25 pat (Guest)
on 2007-01-11 06:25
(Received via mailing list)
Hi Hugh

If you remove the 'return false;' from your onclick handler, it should
work as you want it to.


3fc456adc71a170194d0b1b53e312e18?d=identicon&s=25 Robert Lincolne (brownbox)
on 2008-03-12 09:53
thanks heaps Pat this was exactly the answer I was looking for too!
This topic is locked and can not be replied to.