Forum: Ruby on Rails Getting & validating check_box input in button_to_function

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tony P. (Guest)
on 2009-02-26 08:33
Hi all,

Given below is a snippet of my ruby page.
While clicking on the Edit/Delete buttons, it should:
1. Identify how many chk boxes are checked (If Edit, it should be one)
2. Pass the chk box values (project ids) to the controller methods

I ended up nowhere. Please help me correct the code.
<% chkId = %>
<% i = 0 %>
<% for project in @projects %>
  <td align="center"><% i = i+1 %><% chkId[i] = %><%=
check_box_tag(chkId[i]) %></td>
  <td><%=h project.proj_name %></td>
  <td><%=h project.proj_code %></td>
  <td><%=h project.proj_desc %></td>
  <td><%=h project.manager %></td>
  <td><%=h project.mgr_email %></td>
<% end %>
  <td align="right" colspan="6">
    <%= button_to_function '&nbsp;Create&nbsp;',
:url=>{:action=>'project_creation'}) %>
    <%= button_to_function '&nbsp;Edit&nbsp;',
:url=>{:action=>'project_update'}), :before  => "isSingleSelection()" %>
    <%= button_to_function '&nbsp;Delete&nbsp;',
:url=>{:action=>'delete_project'}, :confirm=>"Are you sure?",
:method=>"delete") %>
<div id="project_creation"></div>
<div id="project_update"></div>
<script type="text/javascript">
  function isSingleSelection(){
    alert("Edit Clicked!");


Do appreciate your help.


Tony P.
This topic is locked and can not be replied to.