JQuery + php implements the all-selected deletion method, and jqueryphp Selects all
The example in this article describes how jQuery + php simply implements all-selected deletion. We will share this with you for your reference. The details are as follows:
<Input type = "checkbox" id = "ckb_selectAll" onclick = "selectAll ()" title = "select/deselect"> <a href = "javascript: void (0 ); "onclick =" del _ () "title =" delete selected data "style =" font-weight: normal "> Delete </a>
Select all checkpoints.
<input type="checkbox" class="ckb" id="+con.id+" value="+con.id+">
The identifier is the delete item, and the same class is named ckb, which facilitates operations. Meanwhile, the id value is cleverly placed in the input for easy acquisition.
Function selectAll () {if ($ ('# ckb_selectAll '). is (': checked') {$ (". ckb "). attr ("checked", true); // select all} else {$ (". ckb "). attr ("checked", false); // cancel all }}
Selected events
Function del _ () {var ids = ''; $ (". ckb "). each (function () {if ($ (this ). is (': checked') {ids + =', '+ $ (this ). val (); // obtain ids one by one}); ids = ids. substring (1); // process the id and remove the first comma if (ids. length = 0) {alert ('select the option to delete ');} else {if (confirm ("are you sure you want to delete? After deletion, it cannot be restored. ") {Url =" action = del_call_record & ids = "+ ids; $. ajax ({type: "post", url: "send. php ", data: url, success: function (json) {if (parseInt (json. counts)> 0) {alert (json. des); location. reload ();} else {alert (json. des) ;}}, error: function (XMLHttpRequest, textStatus) {alert ("Page request error. Please check and try again or contact the administrator! \ N "+ textStatus );}});}}}
Callback deletion is handled using ajax.
↓ Operations on the database in the background to process deletion actions.
$ Ids = trim ($ _ REQUEST ['id']); $ del_ SQL = "DELETE FROM vicidial_call_record WHERE id IN (". $ ids. ")"; // print_r ($ del_ SQL); exit; if (mysqli_query ($ db_conn, $ del_ SQL) {$ counts = "1 "; $ des = "successful";} else {$ counts = "0"; $ des = "failed";} $ json_data = "{"; $ json_data. = "\" counts \":". json_encode ($ counts ). ","; $ json_data. = "\" des \":". json_encode ($ des ). ""; $ json_data. = "}"; echo $ json_data; break;
Complete