开发者

dynamic select population based on result from another select_tag

I have a question with regards to this tricky situation. I have code for a single select box where I can select a year, and based on the year, I want to return all possible values pertaining to that year in another select tag....

<%= select "month_end", "year", MonthEnd.find(:all, :select => 'DISTINCT year',开发者_开发知识库 :order => 'year').collect{|x| [ x.year, x.id ]} %>

I've tried to use observe field but it doesnt work, I need some help please.

Thank you very much for any help, have a great x-mas/new years


i have had the same idea : populating a select_tag based on result from another select_tag. The solution i had was : showing one select_tag and using ajax to send the choice of the user to an action in the controller. The response sent by this action was the list of the choices that the second select will use. The second select will be rendered by a partial and this way you can gave a more nice User Exprience .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜