How to send checkbox checked data using jquery and ajax to struts action class -


below jquery here how checkbox checked data in struts action class using jquery , ajax please tell me

<script>   $(document).ready(function() {     $('#datatables-example').datatable({       responsive : true,       "order":[],                      "columndefs": [ {         "targets": 0,         "orderable": false,         "classname": "dt-center"       }]                                   });      $("#selectall").click(function() {       $('.case').prop('checked', this.checked);                        if ($('.case').prop('checked', this.checked)) {           count = this.checked ? $(".case").length : 0;           smscount.innerhtml = count;         }       });                   $(".case").click(function() {         count = $(".case:checked").length;          if ($(".case").length == $(".case:checked").length) {           $("#selectall").prop("checked", true);         } else {           $("#selectall").prop("checked", false);         }          smscount.innerhtml = count;       });     });   }); </script> 

full coding html table

create variable , getters , setters in action class

private boolean example; public boolean getexample() { return example; } public void setexample(boolean example) { this.example = example; } 

add value attribute checkbox(s)

<input type="checkbox" class="case" value="true" name="example"/>

then use jquery's ajax() function send via post or get

$.ajax({     url: yoururl,     method:'post',     data: $('.case').serialize() }); 

when request submitted example variable either true or false depending if checkbox checked or not.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -