# JavaScript Form Submit with form\_remote\_tag

**URL:** <https://www.ruby-forum.com/t/javascript-form-submit-with-form-remote-tag/142674>\
**Category:** Rails\
**Created:** [July 10, 2008, 10:30am UTC](https://www.ruby-forum.com/t/javascript-form-submit-with-form-remote-tag/142674 "2008-07-10T10:30:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![idledaylight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f07891/32.png) [@idledaylight](https://www.ruby-forum.com/u/idledaylight)\
**Post date:** [July 10, 2008, 10:30am UTC](https://www.ruby-forum.com/t/javascript-form-submit-with-form-remote-tag/142674/1 "2008-07-10T10:30:57Z")

</div>

I am trying to submit a form\_remote\_tag using javascript instead of a  
regular form submit button. Here is my code:

\<%=  
form\_remote\_tag(  
:url=\> { :controller=\>‘store’, :action=\>‘add\_to\_cart\_ajax’, :id =\>  
@product.id, :variation =\> @variations[i].id },  
:html =\> {:name =\> ‘add\_product\_form’},  
:complete =\> “showPopWin(’/store/show\_cart’, 600, 400, null,  
true)”,  
:failure =\> ‘alert(“That item appears to have gone out of stock  
before you were able to add it to your cart.\n\nPlease refresh this  
page.”)’,  
:update =\> ‘items’  
)  
%\>

Add To Cart

When I click the javascript text to submit the form, the ajax doesn’t  
fire. If I use a regular submit button everything works fine. What am  
I doing wrong?

Any help is greatly appreciated!
