[Rails] Newbie: Radiobutton onclick

Abbath abbath at invitel.hu
Thu Dec 29 15:06:54 GMT 2005


Hi,

I would like to make a simple html which displays the contents of a
table from a database. So I put radiobuttons near the titles of the
columns to note and do a sorting by that column. But I don't know how
to implement that the clicking on one of the radiobuttons make the
sorting. The problem is the view part. How to give a radiobutton to
make some action on a click by the helper?

The code is:

-----
<table border="1">
        <tr>
                <% for col in Product.content_columns %>
                <td width="100"><%= radio_button :index, 'head', col.name %><%= col.name %></td>
                <% end%>
        </tr>
        <% for prod in @product %>
                <tr>
                        <% for col in Product.content_columns %>
                                <td>
                                        <%= prod.send(col.name) unless (prod.send(col.name).to_s == "") %>
                                        <%= "&nbsp;" if (prod.send(col.name).to_s == "") %>
                                </td>
                        <% end %>
                </tr>
        <% end %>
        <tr>
</table>
-----

Thanks.

Abbath



More information about the Rails mailing list