# Passing multiple objects with remote\_function

**URL:** <https://www.ruby-forum.com/t/passing-multiple-objects-with-remote-function/182577>\
**Category:** Rails\
**Created:** [January 30, 2010, 9:22am UTC](https://www.ruby-forum.com/t/passing-multiple-objects-with-remote-function/182577 "2010-01-30T09:22:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [January 30, 2010, 9:22am UTC](https://www.ruby-forum.com/t/passing-multiple-objects-with-remote-function/182577/1 "2010-01-30T09:22:59Z")

</div>

Hey,

I can successfully pass a single object from any form field to my  
controller via:

Select Year: \<%= collection\_select(“vehicle”, “year”, @availableYears,  
“year”, “year”,  
{:prompt =\> “Select a year”},  
{:onchange =\> “#{remote\_function(:url =\> {:action  
=\> “update\_from\_year”},  
:with =\>  
“‘vehicle\_year\_id=’+value”)}”}) %\>

What I would like to do is pass all the form values (4) to the  
controller with 1 :onchnage action.

My controller logic needs to replace different page elements according  
to what fields values are set. But the fields may change at different  
times and depending on there current values may need to change each  
other.

My thought was every time any of them changed send along the status of  
all of them so I may check them and act accordingly.

So if anyone knows how i can pass multiple values with :with =\> . Or  
another way to go about getting the values from the controller before  
updating the page that would be great.  
Thanks

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [January 31, 2010, 3:57am UTC](https://www.ruby-forum.com/t/passing-multiple-objects-with-remote-function/182577/2 "2010-01-31T03:57:13Z")

</div>

Hi brianp

```
 You can use submit option with remote_function as with 

```

link\_to\_remote. Please check it here

[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001645](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001645)

Sijo

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [January 31, 2010, 11:21am UTC](https://www.ruby-forum.com/t/passing-multiple-objects-with-remote-function/182577/3 "2010-01-31T11:21:23Z")

</div>

You could try using a :with like so:

:with =\> “$(‘form\_element’).serialize()”)

where ‘form\_element’ is the id of your form.
