Kill lui Lei dog thinkphp project----Enterprise website 16 article bulk Delete completion

Source: Internet
Author: User
Tags form post

When we are doing a site often encounter bulk Delete this option, in fact, it is very simple, we need to use JQ to achieve the effect and then through the form post past the backend can be achieved:

Before we do this, we must first introduce JQ, and my JQ version is 1.8.3, as shown in the following method:

<script>        // in JQ 1.8.3 test successful        $ ("#selall"). Click (function() {             if ($ (this). attr ("checked")) {                $ ('. Selall '). attr ("Checked", "checked");            } Else {                $ ('. Selall '). Removeattr ("checked");            }        );     </script>

Then look at the page effect:

First, the effect is realized, and then the next step, the action of the Lists.html form form is modified to modify it to

And then come to the controller to create one more Tdel method,

Then modify the value of the next lists.html,

If we choose more, we'll use an array to receive the ar_id.

After clicking OK to delete, we can receive an array on the backend as follows:

In order to prevent accidental deletion, we can add a piece of code in the confirmation delete:

onclick= "return confirm (' Are you sure you want to delete this column? ‘);"

This will automatically pop up a dialog box when someone clicks Delete, the effect is as follows:

The next step is to go back to the array we are going to use to implode her, and then he becomes a string form:

 Public functionTdel () {$tdel= I ("Tdel"); $tdel=implode(‘,‘,$tdel);//implode let the array split into string form//dump ($tdel);        $mod= M (' article '); if($mod->delete ($tdel)){            $this->success (' Delete succeeded '); }Else{            $this->success (' Delete failed '); }    }

This allows for bulk deletion.

Kill lui Lei dog thinkphp project----Enterprise website 16 article bulk Delete completion

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.