# Submit form\_remote\_tag with JavaScript

**URL:** <https://www.ruby-forum.com/t/submit-form-remote-tag-with-javascript/142718>\
**Category:** Rails\
**Created:** [July 10, 2008, 8:31pm UTC](https://www.ruby-forum.com/t/submit-form-remote-tag-with-javascript/142718 "2008-07-10T20:31:58Z")\
**Posts on this page:** 3\
**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, 8:31pm UTC](https://www.ruby-forum.com/t/submit-form-remote-tag-with-javascript/142718/1 "2008-07-10T20:31:58Z")

</div>

I’m trying to submit a form\_remote\_tag using javascript instead of an  
input button. However, when I do this the ajax doesn’t fire on submit.  
Is there a way to do this?

---

<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 11, 2008, 7:47am UTC](https://www.ruby-forum.com/t/submit-form-remote-tag-with-javascript/142718/2 "2008-07-11T07:47:09Z")

</div>

try sth. like this:

\<% form\_tag :id =\> “search” do -%\>  
\<%= text\_field\_tag(‘search\_field’, params[:query], :autocomplete  
=\> “on” ) %\>  
\<% end -%\>  
\<%= observe\_field ‘search\_field’, :frequency =\> 1,  
:update =\> “activities”,  
:url =\> { :controller =\> “your\_controller”,  
:action =\> “search”  
},  
:with =\> “query” %\>

this will send a request to your search-method every time the user  
typed sth. into the search\_field.

hope this helps! smn

---

<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 11, 2008, 1:18pm UTC](https://www.ruby-forum.com/t/submit-form-remote-tag-with-javascript/142718/3 "2008-07-11T13:18:35Z")

</div>

one more thing:  
in my above example i used :update =\> “activities”

change “activities” to whatever the id of the element (div, table…)  
is that you want to update

good luck! smn
