# Specify HTML options on select\_year

**URL:** <https://www.ruby-forum.com/t/specify-html-options-on-select-year/130191>\
**Category:** Rails\
**Created:** [February 26, 2008, 8:32am UTC](https://www.ruby-forum.com/t/specify-html-options-on-select-year/130191 "2008-02-26T08:32:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 26, 2008, 8:32am UTC](https://www.ruby-forum.com/t/specify-html-options-on-select-year/130191/1 "2008-02-26T08:32:08Z")

</div>

Rails 1.2.3

It appears that the select\_year helper doesn’t accept HTML attributes as  
part of the options array.

Does anyone have a way to successfully pass an :onchange attribute in to  
the select\_year helper?

I’m going to do it with Javascript directly for now.

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 26, 2008, 11:18am UTC](https://www.ruby-forum.com/t/specify-html-options-on-select-year/130191/2 "2008-02-26T11:18:16Z")

</div>

Hi Wes,

Please could you post the snippet of view code you are using? cheers

Jabbslad

On Feb 26, 7:32 am, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 26, 2008, 7:55pm UTC](https://www.ruby-forum.com/t/specify-html-options-on-select-year/130191/3 "2008-02-26T19:55:32Z")

</div>

Here’s an example:

\<%= select\_year(DateTime.now.year, :start\_year =\> 1960, :end\_year =\>  
DateTime.now.year, :prefix =\> “school”, :field\_name =\> “yearfrom”,  
:include\_blank =\> true) %\>

If you read the source code for select\_year carefully  
([api.rubyonrails.org](http://api.rubyonrails.org)), you’ll see that any regular HTML options do not  
get passed to the “select\_html” call, just option tag values and  
“select\_html” - specific options (which are not HTML options).

I ended up using Prototype to set up the onchange handlers dynamically,  
which, as it turns out, is a better practice, and was actually better  
suited for what I was doing.

Thanks,  
Wes
