# Is there a Rails helper similar to link\_to\_remote but for a form check box instead of a link?

**URL:** <https://www.ruby-forum.com/t/is-there-a-rails-helper-similar-to-link-to-remote-but-for-a-form-check-box-instead-of-a-link/115607>\
**Category:** Rails\
**Created:** [September 26, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/is-there-a-rails-helper-similar-to-link-to-remote-but-for-a-form-check-box-instead-of-a-link/115607 "2007-09-26T20:12:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://www.ruby-forum.com/u/sharon)\
**Post date:** [September 26, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/is-there-a-rails-helper-similar-to-link-to-remote-but-for-a-form-check-box-instead-of-a-link/115607/1 "2007-09-26T20:12:55Z")

</div>

I’m working on a couple of user input forms – one data entry, one  
search – where I’d like to start off by displaying only top-level  
categories. Then, if a user checked one of the top-level categories,  
all the child categories would show for that top-level one.  
(Displaying all the child categories for every parent would be a bit  
overwhelming, it’s a large list.)

I can see how to do this by making the category name a clickable link,  
and using link\_to\_remote, but that’s not an expected UI for a form.  
I’d rather use a check box, but I’d like to avoid trying to write my  
own non-Rails-assisted Ajax from scratch if possible.

Thanks.

---

<div class="post-metadata">

**Author:** ![sharon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://www.ruby-forum.com/u/sharon)\
**Post date:** [September 26, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/is-there-a-rails-helper-similar-to-link-to-remote-but-for-a-form-check-box-instead-of-a-link/115607/2 "2007-09-26T20:18:45Z")

</div>

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

> I’d rather use a check box, but I’d like to avoid trying to write my  
> own non-Rails-assisted Ajax from scratch if possible.

You can use the #remote\_function helper that generates the javascript  
that #link\_to\_remote uses:

\<%= check\_box\_tag :foo, ‘1’, params[:foo], :onclick =\>  
remote\_function(:url =\> …) %\>

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
