# Controlling multiple form\_for with javascript -- please help!

**URL:** <https://www.ruby-forum.com/t/controlling-multiple-form-for-with-javascript-please-help/208432>\
**Category:** Rails\
**Created:** [June 18, 2011, 12:20am UTC](https://www.ruby-forum.com/t/controlling-multiple-form-for-with-javascript-please-help/208432 "2011-06-18T00:20:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 18, 2011, 12:20am UTC](https://www.ruby-forum.com/t/controlling-multiple-form-for-with-javascript-please-help/208432/1 "2011-06-18T00:20:59Z")

</div>

In the show.html.erb view of users (/users/1/), I have a form that  
allows the user to “post” a msg (e.g., “I took out the trash.”)  
Currently, I have that connected to a facebook\_controlller.rb, that  
sends a status update to the user’s FB account if they have “connected  
with facebook” on our site. I want to allow users to control whether  
their post would be broadcasted via facebook, so I added a  
check\_box\_tag to the form\_for posting to act as a gate.

Suppose you log in and you post something, then a partner (e.g., think  
of it as a Twitter follower) can log in and rate your msg on the same  
page using a link\_to url\_for (…).

I have a similar FB status update if you rate a msg (it posted “I just  
rated my partner’s msg…”) I tried adding a similar check\_box\_tag  
for the ratings, and I’m trying to pass a “:share” parameter to the  
ratings\_controller.rb from the users\_controller.rb

Here’s the problem:

1. if I use a check\_box\_tag on the same page, then when the rate url  
is clicked, the msg form\_for post gets triggered and there’s an  
error.

2. I tried implementing javascript so that I could target which form  
on the page gets activated (form\_1 = msg post; form\_2 = check\_box),  
but it seems that I can’t get the DOM to identify the check\_box\_tag.

3. I tried creating a separate form\_for the “:share” parameter. But  
the app breaks, stating that there is an undefined method (presumably  
because I initialized @share = params[:share] in the  
users\_controller.rb; while the app is expecting a model not a  
variable).

Any and all thoughts on this are welcome!
