# Multiple Paramters and observe\_field :with

**URL:** <https://www.ruby-forum.com/t/multiple-paramters-and-observe-field-with/57874>\
**Category:** Rails\
**Created:** [April 15, 2006, 8:42am UTC](https://www.ruby-forum.com/t/multiple-paramters-and-observe-field-with/57874 "2006-04-15T08:42:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [April 15, 2006, 8:42am UTC](https://www.ruby-forum.com/t/multiple-paramters-and-observe-field-with/57874/1 "2006-04-15T08:42:22Z")

</div>

Hi All:

I have searched high and low with no success. Does anyone know of a way  
to pass the values of more than one form field through the :with  
parameter of observe\_field?

Basically I have two fields on the form with number values. When the  
user changes the value of one I would like to send the values of both  
fields to the controller for calculations and return the result to the  
user on the form. If I only pass one of the fields (i.e.  
“‘volume=’+value”) I can get a respnse back to the form, so I am pretty  
sure all my code is good…

I also looked into observe\_form but couldn’t get the Form.serialize  
thing to work. I only want to pass the two values, not the entire form  
which has a considerable amount of inputs on it anyway.

I did find a hint on the Rails wiki:  
[http://wiki.rubyonrails.org/rails/pages/observe\_field+-+Passing+Parameters](http://wiki.rubyonrails.org/rails/pages/observe_field+-+Passing+Parameters)

Though despite my efforts to copy the syntax given in the example, I  
couldn’t get it to work either. Any ideas?

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [April 16, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/multiple-paramters-and-observe-field-with/57874/2 "2006-04-16T17:53:45Z")

</div>

Anybody out there?

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [April 18, 2006, 4:55am UTC](https://www.ruby-forum.com/t/multiple-paramters-and-observe-field-with/57874/3 "2006-04-18T04:55:03Z")

</div>

Hello:

Just in case someone ever reads this…I found a solution, which you can  
see on the Rails wiki:  
[http://wiki.rubyonrails.org/rails/pages/observe\_field+-+Passing+Parameters](http://wiki.rubyonrails.org/rails/pages/observe_field+-+Passing+Parameters)

The solution involved concatenating a string of values from various form  
feilds using the $F function from the Prototype library. Good Luck…

David

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [April 18, 2006, 4:55am UTC](https://www.ruby-forum.com/t/multiple-paramters-and-observe-field-with/57874/4 "2006-04-18T04:55:50Z")

</div>

David H. wrote:

> Hello:
> 
> Just in case someone ever reads this…I found a solution, which you can  
> see on the Rails wiki:  
> [http://wiki.rubyonrails.org/rails/pages/observe\_field+-+Passing+Parameters](http://wiki.rubyonrails.org/rails/pages/observe_field+-+Passing+Parameters)
> 
> The solution involved concatenating a string of values from various form  
> feilds using the $F function from the Prototype library. Good Luck…
> 
> David

Why not use observe\_form?

It will monitor all the fields in your form, and you can act only in the  
specific cases you need to process.

Jeff C.man
