<!DOCTYPE html><html><head><title>how to delete multiple records using checkbox in codeigniter - itsolutionstuff.com</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script></head><body><div class="container"><div class="row"><div class="col-lg-12 margin-tb"><div class="pull-left"><h2>how to delete multiple records using checkbox in codeigniter - itsolutionstuff.com</h2></div></div></div><button style="margin-bottom: 10px" class="btn btn-primary delete_all" data-url="/itemDelete">Delete All Selected</button><table class="table table-bordered" style="margin-top:20px"><thead><tr><th width="50px"><input type="checkbox" id="master"></th><th>Title</th><th>Description</th></tr></thead><tbody><?php foreach ($data as $item) { ?><tr><td><input type="checkbox" class="sub_chk" data-id="<?php echo $item->id; ?>"></td><td><?php echo $item->title; ?></td><td><?php echo $item->description; ?></td></tr><?php } ?></tbody></table></div><script type="text/javascript">$(document).ready(function () {$('#master').on('click', function(e) {if($(this).is(':checked',true)){$(".sub_chk").prop('checked', true);} else {$(".sub_chk").prop('checked',false);}});$('.delete_all').on('click', function(e) {var allVals = [];$(".sub_chk:checked").each(function() {allVals.push($(this).attr('data-id'));});if(allVals.length <=0){alert("Please select row.");} else {var check = confirm("Are you sure you want to delete this row?");if(check == true){var join_selected_values = allVals.join(",");$.ajax({url: $(this).data('url'),type: 'POST',data: 'ids='+join_selected_values,success: function (data) {console.log(data);$(".sub_chk:checked").each(function() {$(this).parents("tr").remove();});alert("Item Deleted successfully.");},error: function (data) {alert(data.responseText);}});$.each(allVals, function( index, value ) {$('table tr').filter("[data-row-id='" + value + "']").remove();});}}});});</script></body></html>
Sunday, April 21, 2019
Creative code : Delete Multiple Rows using Checkbox.
Subscribe to:
Post Comments (Atom)
-
Composer is a major part of the Laravel MVC Framework, but it also exists without Laravel. In fact you could use it in any project. This a...
-
How to Answer Technical Questions Like a Pro Answering technical interview questions is all about showing off your problem-solving skills an...
-
Vuetify is a popular UI framework for Vue apps. In this article, we’ll look at how to work with the Vuetify framework. Color Picker Inputs W...
No comments:
Post a Comment