srikanth
2008-Dec-26 17:37 UTC
how to get the value of dropdown box selected using collect_select()?
Hi, I am trying to get the value of ''contenttype_id'' value from the ''streams'' table like: <%= collection_select (:stream, :contenttype_id,@contenttypes,:id,:name),{},{onchange => "switchdiv(value)";}%> here i want to recieve the vaule of selected option in switchdiv( ) as argument. my collection_select dropdown box contain names as video,audio,image and speech with having values as 1,2,3 and 4 respectively. so if i hardcoded as value = 1 in switchdev() function like switchdiv(1) am able do functionality what i implemented in switchdiv function, instead of hardcdoing i want to get the "value" of "name" from dropdownbox. ex:if i select name as ''video'' i shoud get the value as ''1'' can anyone give idea to get the value from collect_select? thanks Srikanth --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-26 19:51 UTC
Re: how to get the value of dropdown box selected using collect_select()?
On 26 Dec 2008, at 17:37, srikanth wrote:> > Hi, > > I am trying to get the value of ''contenttype_id'' value from the > ''streams'' table like: > > <%= collection_select > (:stream, :contenttype_id,@contenttypes,:id,:name),{},{onchange => > "switchdiv(value)";}%> > > here i want to recieve the vaule of selected option in switchdiv( ) as > argument. > my collection_select dropdown box contain names as video,audio,image > and speech with having values as 1,2,3 and 4 respectively. > > so if i hardcoded as value = 1 in switchdev() function like > switchdiv(1) am able do functionality what i implemented in switchdiv > function, > > instead of hardcdoing i want to get the "value" of "name" from > dropdownbox. > ex:if i select name as ''video'' i shoud get the value as ''1'' > can anyone give idea to get the value from collect_select? > thanksswitchdiv($F(''id_of_the_select_tag'')) will do the trick if you have prototype library loaded Fred> > Srikanth > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---