# Collection\_select with params :onchange

**URL:** <https://www.ruby-forum.com/t/collection-select-with-params-onchange/145584>\
**Category:** Rails\
**Created:** [August 11, 2008, 8:14pm UTC](https://www.ruby-forum.com/t/collection-select-with-params-onchange/145584 "2008-08-11T20:14:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@maite](https://www.ruby-forum.com/u/maite)\
**Post date:** [August 11, 2008, 8:14pm UTC](https://www.ruby-forum.com/t/collection-select-with-params-onchange/145584/1 "2008-08-11T20:14:46Z")

</div>

hello list

this my code

\<%= collection\_select (“fuentes”, “id”, @fuente, :id, :nombre,  
{:prompt =\> ‘Seleccione mercado’},  
:onchange=\> {"$(‘btn4’).visualEffect(‘Appear’)"})%\>

 \<%= submit\_tag "Crear url" %\> 

params onchage doesÂ´t work!!! why???

thanks everybody

---

<div class="post-metadata">

**Author:** ![maite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@maite](https://www.ruby-forum.com/u/maite)\
**Post date:** [August 11, 2008, 11:38pm UTC](https://www.ruby-forum.com/t/collection-select-with-params-onchange/145584/2 "2008-08-11T23:38:51Z")

</div>

Maite P. wrote:

> hello list
> 
> this my code
> 
> \<%= collection\_select (“fuentes”, “id”, @fuente, :id, :nombre,  
> {:prompt =\> ‘Seleccione mercado’},  
> :onchange=\> {"$(‘btn4’).visualEffect(‘Appear’)"})%\>
> 
> \<%= submit\_tag "Crear url" %\> 
> 
> params onchage doesÂ´t work!!! why???
> 
> thanks everybody
> 
> Try putting the :onchange portion in { }. I have a similar drop down  
> that once you make a selection a remote\_function call is activated and  
> that’s when all the magic happens. I had the same problem as you when I  
> was trying to get it to work and that is the solution that I found. Here  
> is what my code looks like:
> 
> \<%= collection\_select(“user”, “contact\_country” ,  
> Countrycode.find( :all, :order =\> ‘id’ ),  
> :id, :country, {:include\_blank =\> true, :selected =\> xxxxx},  
> {:onchange =\> remote\_function( :update =\> ‘contact\_country’, :url =\>  
> { :action =\> ‘set\_contact\_country’, :id =\> @user.id}, :with =\>  
> “‘select=’ +  
> escape(value)” )} )%\>
> 
> Hope this helps,
> 
> -S

---

<div class="post-metadata">

**Author:** ![maite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@maite](https://www.ruby-forum.com/u/maite)\
**Post date:** [August 12, 2008, 1:58am UTC](https://www.ruby-forum.com/t/collection-select-with-params-onchange/145584/3 "2008-08-12T01:58:19Z")

</div>

thanks, now it is work !!! 🙂

---

<div class="post-metadata">

**Author:** ![maite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@maite](https://www.ruby-forum.com/u/maite)\
**Post date:** [August 12, 2008, 9:52pm UTC](https://www.ruby-forum.com/t/collection-select-with-params-onchange/145584/4 "2008-08-12T21:52:42Z")

</div>

On 11 Aug 2008, at 19:14, Maite P. wrote:

> \<%= submit\_tag "Crear url" %\> 
> 
> params onchage does´t work!!! why???
> 
> because there’s no such thing as a javascript visualEffect method.  
> There is a rails helper visual\_effect, that will spit out the  
> corresponding javascript.  
> Either use that, or just write the javascript yourself:
> 
> $(‘btn4’).appear()  
> or
> 
> new Effect.Appear(‘btn4’)
