lundi 26 septembre 2016

How to get the values of checkbox on jQuery datatable

I have a big problem, I cannot get the values of every chekbox on table, I get just values of the page on focus even if I check others checkbox on others page, it doesn't work , i want to get every values checked when i submit the form,this is what i done :

`

function checkbox() {
var data =[];
$('.person_data').each(function() {
if(this.checked == true){
data.push(this.value);
}
});
var str = data.join(', ');
$.ajax({
url : 'getcheck',
method : 'get',
ContentType : 'json',
data : {
check : str
},
success : function(response) {
}
});
}
<table width="100%" class="table table-striped table-bordered table-hover" id="example">
 <thead>
  <tr>
   <th><input type="checkbox" name="select_all" id="select_all"  value="Tous"/>&nbsp;&nbsp;Tous</th>
   <th style="width: 130px;">Module</th>
 </thead>
 <c:choose>
   <c:when test="${fn:length(List)>0}">
   <tbody>
      <c:forEach items="${List}" var="var">
      <tr>
      <td>                                 
      <input type="checkbox" class="person_data"    value="${var.id}"/>
       </td>   
       <td><c:out value="${var.module}"></c:out><td>
       </tr>    
       </c:forEach>   
   </tbody>
   </c:when>
 </c:choose>
</table>

`




Aucun commentaire:

Enregistrer un commentaire