How to add or remove a value inside a table cell on selection / de-selection of checkbox of that row, trying to submit the value via Jquery?

Posted by Raul on Stack Overflow See other posts from Stack Overflow or by Raul
Published on 2012-09-30T15:05:41Z Indexed on 2012/09/30 15:37 UTC
Read the original article Hit count: 158

Here is the table:

<%= form_tag '', :id => "costs" do %>
<table class="table table-bordered" id="service_cost">
<% @services.each do |service|  %>
<tbody>
<tr>
<td><%= check_box_tag :open_service,  {}, false, :class => 'checkable' %></td>  
<td><%= service.phone %></td>
<td><%= service.internet %></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><%= service.house_keeping  %> </td>
<td>0.0 </td>
    <td><%= service.laundry %></td>
    <td><%= text_field_tag "service_cost", service.total, :class => "input-small" %></td>
</tr>
<% end %>

when the form gets submitted, the javascript gets into action:

$("#costs").submit(function(){
  formData=$("#costs").serializeArray();
   processFormData(formData)
return false;
});

This ensures form submission on selecting the checkbox:

$('.checkable').live('change', function() {
      $(this).parents('form:first').submit();

});

But, what I am looking for is adding or removing a cell value based on checkbox selection/de-selection and submitting it, kindly suggest a way to do it.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery