Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
checkbox instead of dropdown
Remco Swoany
10/3/2007 5:09:00 PM
Hi,
I am a RoR newby. The code below shows the categorie names, in a
dropdown from the categories table and that works fine. But now i want
to show the categories through checkboxen. How can i realise that??
<select name="recipe[categorie_id]">
<% @categories.each do |categorie| %>
<option value="<%= categorie.id %>"
<%= 'selected' if categorie.id == @recipe.categorie_id %>>
<%= categorie.name %>
</option>
<% end %>
</select>
Grtz..remco
--
Posted via
http://www.ruby-...
.
2 Answers
John Joyce
10/3/2007 6:08:00 PM
0
On Oct 3, 2007, at 12:09 PM, Remco Swoany wrote:
> Hi,
>
> I am a RoR newby. The code below shows the categorie names, in a
> dropdown from the categories table and that works fine. But now i want
> to show the categories through checkboxen. How can i realise that??
>
>
>
> <select name="recipe[categorie_id]">
> <% @categories.each do |categorie| %>
> <option value="<%= categorie.id %>"
> <%= 'selected' if categorie.id == @recipe.categorie_id %>>
> <%= categorie.name %>
> </option>
> <% end %>
> </select>
>
> Grtz..remco
> --
> Posted via
http://www.ruby-...
.
>
For this kind of question you should really check the Rails list.
Jeremy Woertink
10/3/2007 7:00:00 PM
0
Remco Swoany wrote:
> Hi,
>
> I am a RoR newby. The code below shows the categorie names, in a
> dropdown from the categories table and that works fine. But now i want
> to show the categories through checkboxen. How can i realise that??
>
>
>
> <select name="recipe[categorie_id]">
> <% @categories.each do |categorie| %>
> <option value="<%= categorie.id %>"
> <%= 'selected' if categorie.id == @recipe.categorie_id %>>
> <%= categorie.name %>
> </option>
> <% end %>
> </select>
>
> Grtz..remco
Check out the rails doc
http://api.rubyon...
You would put the check_box inside an iteration. so..
<% @categories.each do |category| %>
<%= check_box(category, name) %>
<% end %>
~Jeremy
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
checkbox instead of dropdown
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password