Hi, stuck with another little problem, select lists / drop down boxes.
Tried to avoid these because the code looks uber scary.
Anyway I''ve created a Hash Array called gender:
@gender = [''Man'' => ''male'',
''Woman'' => ''female'']
here you''ve got the key (being the english name) and the value (the
generic equivalent).
what I want to do is make a drop-down single-selection box use these
key/value properties to render it correctly,
<%= select("search", "type", @gender) %>
...this doesn''t work but what i''d like is generate the form
code...
<select name="search" id="type">
<option value="male">Man</option>
<option value="female">Woman</option>
</select>
I''d then read the value off the form via:
@selection = params[:search]
Where am I going wrong?, I know i need some kind of {key, value} clause
in the select() control but unsure where.
Any help really appreciated,
Sincerely
John.
--
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
-~----------~----~----~----~------~----~------~--~---
maybe options_for_select would do the trick? http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000516 -- 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller wrote:> maybe options_for_select would do the trick? > http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000516may well, thanks for that Thornsten ;-) will try that tonight and see how it goes (god i love you people!) -- 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 -~----------~----~----~----~------~----~------~--~---