rails and rails only
2009-Jan-28 11:37 UTC
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Luke Pearce
2009-Jan-29 08:13 UTC
Re: How to give onchange for select_year rails helper....
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: http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001489 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---