# Forcing onChange in a partial

**URL:** <https://www.ruby-forum.com/t/forcing-onchange-in-a-partial/168949>\
**Category:** Rails\
**Created:** [May 27, 2009, 5:01pm UTC](https://www.ruby-forum.com/t/forcing-onchange-in-a-partial/168949 "2009-05-27T17:01:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JannaB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@JannaB](https://www.ruby-forum.com/u/JannaB)\
**Post date:** [May 27, 2009, 5:01pm UTC](https://www.ruby-forum.com/t/forcing-onchange-in-a-partial/168949/1 "2009-05-27T17:01:38Z")

</div>

I have a partial view which incorporates on onChange option in a form.  
It works great when I actually change the select box which it is an  
option to. However, when the div which contains this partial first  
shows, the onChange doesn;t fire. How can I force this to fire when it  
is first shown? Thanks Janna B,

\<%= f.label :country %\>  
  
\<%= f.country\_select :country, Carmen.default\_country, {},  
{  
:onChange =\> remote\_function( :url =\> { :action =\>  
‘\_get\_states’ }, :update =\> “state”, :with =\> “‘country=’ +value”)  
} %\>
