# Problem submiting value, form\_for, link-to-remote, javascrip

**URL:** <https://www.ruby-forum.com/t/problem-submiting-value-form-for-link-to-remote-javascrip/190074>\
**Category:** Rails\
**Created:** [June 13, 2010, 1:50pm UTC](https://www.ruby-forum.com/t/problem-submiting-value-form-for-link-to-remote-javascrip/190074 "2010-06-13T13:50:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [June 13, 2010, 1:50pm UTC](https://www.ruby-forum.com/t/problem-submiting-value-form-for-link-to-remote-javascrip/190074/1 "2010-06-13T13:50:41Z")

</div>

This is my form. It creates a comment in the database but won’t pass the  
‘body’ value. I think the problem is passing the variable to javascript.  
Can anyone help?

\<% form\_for :comment, :url=\>story\_comments\_path(@story), :name =\>  
‘form’ do |form| %\>

 Comment: 
\<%= form.text\_field :body %\>
 \<%= link\_to\_remote('comment',{ :url =\> {:controller =\> 'comments' , :action =\> 'create', :story\_id =\> @story.id, :method =\> 'get', :with =\> 'serialize\_fields()' }}) %\> \<% end %\>

This is the javascript.

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [June 16, 2010, 2:59pm UTC](https://www.ruby-forum.com/t/problem-submiting-value-form-for-link-to-remote-javascrip/190074/2 "2010-06-16T14:59:40Z")

</div>

Neil B. wrote:

> This is my form. It creates a comment in the database but won’t pass the  
> ‘body’ value. I think the problem is passing the variable to javascript.  
> Can anyone help?
> 
> \<% form\_for :comment, :url=\>story\_comments\_path(@story), :name =\>  
> ‘form’ do |form| %\>
> 
> Comment: 
> \<%= form.text\_field :body %\>
> \<%= link\_to\_remote('comment',{ :url =\> {:controller =\> 'comments' , :action =\> 'create', :story\_id =\> @story.id, :method =\> 'get', :with =\> 'serialize\_fields()' }}) %\> \<% end %\>
> 
> This is the javascript.

I tried this too

:with=\>"‘body’ + $F(‘body’)"

That doesn’t work either. How can I pass this parameter?

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/problem-submiting-value-form-for-link-to-remote-javascrip/190074/3 "2010-06-17T16:22:04Z")

</div>

On Jun 13, 12:50 pm, Neil B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This is my form. It creates a comment in the database but won’t pass the  
> ‘body’ value. I think the problem is passing the variable to javascript.  
> Can anyone help?

Your serialize\_form method looks borked. You could use the  
remote\_form\_for method alternatively, prototype already provides a  
serialise method for forms - $(‘id\_of\_the\_form’).serialize() will  
serialise all then inputs in the form

Fred

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/problem-submiting-value-form-for-link-to-remote-javascrip/190074/4 "2010-06-17T16:22:34Z")

</div>

Dear Fred;

so thanks, for ur help.  
am so new to ROR, and was so interested on AJAX,  
i used the ActiveScaffod instead of it and all is okey.

bytheway, tnx2much  
@};-

On Sun, Jun 13, 2010 at 8:12 PM, Frederick C. \<  
removed\_email\_address@domain.invalid\> wrote:

> serialise method for forms - $(‘id\_of\_the\_form’).serialize() will
> 
> > \<% form\_for :comment, :url=\>story\_comments\_path(@story), :name =\>  
> > ‘serialize\_fields()’ }}) %\>
> 
> .  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
