Select and passing some javascript

Hello,

After reading and reading the documentation, I can’t append some
javascript function into a select.

It’s not possible ?

documentation:

select(object, method, choices, options = {}, html_options = {})

some code:

return select(:id, :year, [ [‘2008’, 2008],
[‘2007’, 2007],
[‘2006’, 2006]], :selected => session[:user_year], :onChange =>
‘enterprise_function();’ )

what I want:

2007 2006 2005

On 2 Dec 2007, at 22:18, Raimon Fs wrote:

some code:

return select(:id, :year, [ [‘2008’, 2008],
[‘2007’, 2007],
[‘2006’, 2006]], :selected => session[:user_year], :onChange
=>
‘enterprise_function();’ )

I believe you want

select(:id, :year, [ [‘2008’, 2008],
[‘2007’, 2007],
[‘2006’, 2006]], {:selected =>
session[:user_year]}, :onChange =>
‘enterprise_function();’ )

Fred

Frederick C. wrote:

I believe you want

select(:id, :year, [ [‘2008’, 2008],
[‘2007’, 2007],
[‘2006’, 2006]], {:selected =>
session[:user_year]}, :onChange =>
‘enterprise_function();’ )

thanks, it works …

so, reading in the docs:

select(object, method, choices, options = {}, html_options = {})

you put the onChange… between curly braces {} in the options, and what
can we put in the html_options {}

thanks !

raimon

On Dec 3, 7:44 am, Raimon Fs [email protected] wrote:

so, reading in the docs:

select(object, method, choices, options = {}, html_options = {})

you put the onChange… between curly braces {} in the options, and what
can we put in the html_options {}

It’s the other way round. The first hash is options, which takes
selected and a few other things. The second hash (html_options) goes
straight out to the rendered html, so if you put ‘foo’ => ‘bar’ then
your select tag would have foo=“bar” as an attribute.

Fred

Frederick C. wrote:

On Dec 3, 7:44 am, Raimon Fs [email protected] wrote:

so, reading in the docs:

select(object, method, choices, options = {}, html_options = {})

you put the onChange… between curly braces {} in the options, and what
can we put in the html_options {}

It’s the other way round. The first hash is options, which takes
selected and a few other things. The second hash (html_options) goes
straight out to the rendered html, so if you put ‘foo’ => ‘bar’ then
your select tag would have foo=“bar” as an attribute.

Fred

ok, now I understand …

thanks again!

raimon

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs