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

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.
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.
-----------------------------------------------------------
<tr>
  <th>Select</th><th>Name</th><th>Code</th><th>Description</th><th>Manager</th><th>Manager
Email</th>
</tr>
<% chkId = Array.new %>
<% i = 0 %>
<% for project in @projects %>
<tr>
  <td align="center"><% i = i+1 %><% chkId[i] = project.id.to_s %><%=
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>
</tr>
<% end %>
<tr>
  <td align="right" colspan="6">
    <%= button_to_function '&nbsp;Create&nbsp;',
      remote_function(:update=>"project_creation",
:url=>{:action=>'project_creation'}) %>
    <%= button_to_function '&nbsp;Edit&nbsp;',
      remote_function(:update=>"project_update",
:url=>{:action=>'project_update'}), :before  => "isSingleSelection()" %>
    <%= button_to_function '&nbsp;Delete&nbsp;',
      remote_function(:update=>"admin_project",
:url=>{:action=>'delete_project'}, :confirm=>"Are you sure?",
:method=>"delete") %>
  </td>
</tr>
</table>
<div id="project_creation"></div>
<div id="project_update"></div>
</div>
<script type="text/javascript">
  function isSingleSelection(){
    alert("Edit Clicked!");
  }

</script>
-----------------------------------------------------------

Do appreciate your help.

Thanks,

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