How to give onchange for select_year rails helper

<%=select_year(Date.today,:include_blank=>true, :start_year =>
Date.today.strftime("%Y").to_i, :end_year => 1999)%>

i am using rhis helper… now i want to give onchange here…

Please help me to solve this …

thanks in advance
JK

rails and rails only wrote:

<%=select_year(Date.today,:include_blank=>true, :start_year =>
Date.today.strftime(“%Y”).to_i, :end_year => 1999)%>

i am using rhis helper… now i want to give onchange here…

If you check out the api:

select_year(date, options = {}, html_options = {})

So to add an onchange you need to use the html_options hash…

<%=select_year(Date.today,{:include_blank=>true, :start_year =>
Date.today.strftime(“%Y”).to_i, :end_year => 1999}, {:onchange =>
‘myjsfunction();’})%>

Note the curly braces. Ruby is pretty clever in that it will convert
the last set of symbols into a hash which is pretty helpful but not if
you want be able to send the html_options hash. However if you
specifically mark the hashes (i.e. put curly braces around them) you can
send both hashes.

Cheers
Luke