thinkphp Bulk Delete

Source: Internet
Author: User

1. Forms   Submit Data <form action= "__url__/deleteselected"  method= "POST" ></form>2.js validation <a  href= "#"  onclick= "Delall ()"  class= "delete" >  bulk delete </a><td class= "TC" > <input name= "id[]"  value= "<{$voList .txt_id}>"  type= "checkbox" ></td><script >    function delall () {      var chk_value  =[];       $ (' input[name= ' id[] "]:checked '). each (function () {          chk_value.push ($ (this). Val ());                console.log (chk_value);       var submit = confirm (chk_value.length==0 ? ') You have not selected any content yet! ': ' Do you need to remove ' id  ' +chk_value+ ');       if  (Submit)  {         window.location.href =  "__url__/deleteselected/id/" +chk_value;        return  false;      } else{         return false;      };    } </script>   3. Delete  //Bulk Delete     public function deleteselected () {          $getid  = $_request[' id ']; //gets the value of the selected check box          dump ($getid);        if  (! $getid)               $this->error (' record not selected ');  //no option to prompt information          $getids  = implode (', ',  $getid);  //choose more than one, It is used to connect the values ( = is_array)          $id ($getid)     $getids  :  $getid,  //if it is an array, it will be used, connected value to the $id, otherwise it will not be obtained, the number of concatenated values      //the last data operation,          $Result  = d ("Txt")->delete ($id);          $say  =  ' delete Success ';        if  ($Result  === false)  {             $this Error (' operation failed ');        } else {              $this->success ($say);         }    }


thinkphp Bulk Delete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.