# Ajax without submti button?

**URL:** <https://www.ruby-forum.com/t/ajax-without-submti-button/115552>\
**Category:** Rails\
**Created:** [September 26, 2007, 6:43am UTC](https://www.ruby-forum.com/t/ajax-without-submti-button/115552 "2007-09-26T06:43:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 26, 2007, 6:43am UTC](https://www.ruby-forum.com/t/ajax-without-submti-button/115552/1 "2007-09-26T06:43:07Z")

</div>

I have a drop down list, how can I set it up to send request when  
selecting an option rather than pressing submit button after selection?

And how can I save values of checkboxex/radio buttons without submit?

Thanks

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 26, 2007, 11:19am UTC](https://www.ruby-forum.com/t/ajax-without-submti-button/115552/2 "2007-09-26T11:19:24Z")

</div>

Just use add :onchange attribute to your select tag and put in a  
remote\_function to send your form via AJAX. You can use the prototype  
function Form.serialize to send all the form elements.

See here for example:

[http://onrails.org/articles/2006/05/01/remote\_function-with](http://onrails.org/articles/2006/05/01/remote_function-with)

`
<%= select_tag “content_type”,
options_for_select(content_type_options),
{ :onchange =>
remote_function(
:url => {:action => ‘filter_by_content’},
:with => ‘Form.Element.serialize(this)’) } %>
`

Cheers  
Luke

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 26, 2007, 12:32pm UTC](https://www.ruby-forum.com/t/ajax-without-submti-button/115552/3 "2007-09-26T12:32:12Z")

</div>

doesnt work for me

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 26, 2007, 12:50pm UTC](https://www.ruby-forum.com/t/ajax-without-submti-button/115552/4 "2007-09-26T12:50:59Z")

</div>

Vapor … wrote:

> I have a drop down list, how can I set it up to  
> send request when selecting an option rather  
> than pressing submit button after selection?
> 
> And how can I save values of checkboxex/radio  
> buttons without submit?

I think observe\_field may be what you’re looking for. Radio buttons may  
be  
problematic, but it works very well with check boxes, drop downs, and  
other  
form controls.

HTH,  
Bill
