Tony Puthenveettil
2009-Feb-26 06:33 UTC
Getting & validating check_box input in button_to_function
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 '' Create '',
remote_function(:update=>"project_creation",
:url=>{:action=>''project_creation''}) %>
<%= button_to_function '' Edit '',
remote_function(:update=>"project_update",
:url=>{:action=>''project_update''}), :before =>
"isSingleSelection()" %>
<%= button_to_function '' Delete '',
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 Puthenveettil
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---