Forum: Ruby on Rails how to get the value of dropdown box selected using collect_select()?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E38118c6d20b4544e424fd700571e090?d=identicon&s=25 srikanth (Guest)
on 2008-12-26 18:38
(Received via mailing list)
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-12-26 20:52
(Received via mailing list)
On 26 Dec 2008, at 17:37, srikanth wrote:

> here i want to recieve the vaule of selected option in switchdiv( ) as
> 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

switchdiv($F('id_of_the_select_tag')) will do the trick if you have
prototype library loaded

Fred
This topic is locked and can not be replied to.