Suggested have JS Foundation, understand jquery,thinkphp, nonsense don't say more below on code
"———— HTML ————"
thinkphp loop display the data fid is given a marquee <volist name= "data" id= "VO" ><tr> <td><input type= "checkbox" Value= "{$vo. FID}"/></td>//can be added in the following TD input parameters </tr></volist><tr><th width= "> <input type= "checkbox" id= "All"/> Select all </th><th width= "up" ><input type= "button" value= "Select All" class= " BTN "id=" SelectAll "/></th><th width=" "><input type=" button "value=" All not selected "class=" btn "id=" unselect "/></th><th><input type=" button "value=" reverse select "class=" btn "id=" reverse "/></th> <th width= "> <a href=" javascript:void (0), "rel=" external nofollow "onclick=" del () "title=" Delete selected data "> Delete </a> </th> </tr>
"———— jsvascript ————"
<script>//Multi-Select $ ("#all"). Click (function () {if (this.checked) {$ ("#list: CheckBox"). attr ("checked ", true); }else{$ ("#list: CheckBox"). attr ("checked", false); } }); When the point to the Select All button is $ ("#selectAll"). Click (function () {$ ("#list: CheckBox, #all"). attr ("Checked", true); }); Do not select $ ("#unSelect"). Click (function () {$ ("#list: CheckBox, #all"). attr ("checked", false); }); Uncheck $ ("#reverse"). Click (function () {$ ("#list: CheckBox"). each (function () {$ (this). attr ("Checked", !$ (This). attr ("checked")); }); Allcheck (); }); Delete Function del () {var valarr = new Array; $ ("#list: checkbox[checked]"). each (function (i) {valarr[i] = $ (this). Val (); }); var vals = Valarr.join (', ');//array converts a comma-separated string if (Valarr.length = = 0) {alert (' Select option to delete '); }else{if (Confirm ("OK delete?") It will not be recoverable after deletion. ")) {var data={name:vals}; $.ajax ({ Type: "Post", url: "{: U (' College/school/faculty_del ')}",//url is TP method (Controller/method) Data:data, Success:function (JSON) {var obj = eval (' (' + JSON + ') ');//returns the JSON converted to the JS object if (parseint (obj.counts) > 0) {alert (obj.des); Location.reload (); } else {alert (obj.des); }}, Error:function (XMLHttpRequest, textstatus) {alert ("page request error, please check retry or contact administrator! \ n "+ textstatus); } }); }}}</script>
"———— PHP ————"
Public Function Faculty_del () { $fid = Trim ($_post[' name '); The following is the query condition $bname [' deletemark '] = 0; $res = $this->faculty_model ->where (Array (' FID ' =>array (' in ', $fid)) ->save ($bname); Query conditions for your query criteria, my side for the tombstone, modify the field value is good// echo $this->faculty_model->getlastsql ();// Var_dump ($res);// exit; if ($res) { $counts = "1"; $des = "Success"; } else { $counts = "0"; $des = "Failed"; } $json _data = "{"; $json _data.= "\" counts\ ":". Json_encode ($counts). ","; $json _data.= "\" des\ ":". Json_encode ($des). ""; $json _data.= "}"; echo $json _data; Exit; }
Because it is asynchronous so you send the data are viewed in the console, the current page is not output, do not go to the page to find.
The above is a small part of the introduction of PHP (thinkphp) based on the implementation of +jquery Ajax multi-Select uncheck Delete data function, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to you. Thank you very much for your support for topic.alibabacloud.com!