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>
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
Post a Comment