# Checkbox and Ajax

**URL:** <https://www.ruby-forum.com/t/checkbox-and-ajax/114609>\
**Category:** Rails\
**Created:** [September 17, 2007, 1:21pm UTC](https://www.ruby-forum.com/t/checkbox-and-ajax/114609 "2007-09-17T13:21:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradigan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/87869e/32.png) [@bradigan](https://www.ruby-forum.com/u/bradigan)\
**Post date:** [September 17, 2007, 1:21pm UTC](https://www.ruby-forum.com/t/checkbox-and-ajax/114609/1 "2007-09-17T13:21:38Z")

</div>

hello, I am trying to display a Textarea if a user checks the checkbox  
and hides the textarea if the checkbox is not clicked. I can get the  
display working properly, however the actual checkbox is not actually  
checking. It is staying blank (not checked) no matter how many times I  
click it.  
Here is my code

\<%= check\_box “event”, “has\_policy”, “onclick” =\>  
“Effect.toggle(‘policy’); return false;” %\>  
Yes I want add a policy/terms  
agreement

 \<%= form.text\_area :policy\_a, :id=\> 'field19', :cols =\> 50, :rows =\> 10, :class =\> "medium" %\>

---

<div class="post-metadata">

**Author:** ![bradigan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/87869e/32.png) [@bradigan](https://www.ruby-forum.com/u/bradigan)\
**Post date:** [September 17, 2007, 1:21pm UTC](https://www.ruby-forum.com/t/checkbox-and-ajax/114609/2 "2007-09-17T13:21:49Z")

</div>

On 9/13/07, bradigan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yes I want add a policy/terms  
> agreement

I’m guessing that “return false” is preventing the onclick from taking  
its default action, which is to check or uncheck the box.

---

<div class="post-metadata">

**Author:** ![bradigan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/87869e/32.png) [@bradigan](https://www.ruby-forum.com/u/bradigan)\
**Post date:** [September 25, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/checkbox-and-ajax/114609/3 "2007-09-25T23:07:17Z")

</div>

So if you try ‘return true;’ is it always checked?

---

<div class="post-metadata">

**Author:** ![bradigan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/87869e/32.png) [@bradigan](https://www.ruby-forum.com/u/bradigan)\
**Post date:** [September 25, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/checkbox-and-ajax/114609/4 "2007-09-25T23:08:19Z")

</div>

> I’m guessing that “return false” is preventing the onclick from taking  
> its default action, which is to check or uncheck the box.

I thought same thing. I tried that as well, but it broke the Toggle  
event.
