Forum: Ruby on Rails Select Box population

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.
13e43a569b89bb1bfb39df4fcfcdde1f?d=identicon&s=25 Mike (Guest)
on 2007-03-10 15:45
I would like to populate a select box in rails with the values 0 - 100 -
how can this be done in rails?
13e43a569b89bb1bfb39df4fcfcdde1f?d=identicon&s=25 Mike (Guest)
on 2007-03-10 16:31
Mike wrote:
> I would like to populate a select box in rails with the values 0 - 100 -
> how can this be done in rails?

any ideas anyone?
933c05ef3dbe1454bd213bc08777ef63?d=identicon&s=25 macarthy (Guest)
on 2007-03-10 18:03
(Received via mailing list)
> > I would like to populate a select box in rails with the values 0 - 100 -
> > how can this be done in rails?
>
> any ideas anyone?

<% 1.upto(100) do |i| %>
 <option > <%= i %></option>
<% end %>

Justin
8bc543795b502900b5333aea73ad5533?d=identicon&s=25 Eden Li (edenli)
on 2007-03-10 18:16
(Received via mailing list)
Also,

<%= select_tag("value", options_for_select((0..100).map { |v| [v.to_s,
v] })) %>
13e43a569b89bb1bfb39df4fcfcdde1f?d=identicon&s=25 Mike (Guest)
on 2007-03-11 18:18
thanks a lot guys - very helpful!
This topic is locked and can not be replied to.