Home > Backend Development > PHP Tutorial > How to use thinkPHP to pop up a confirmation box before deleting data

How to use thinkPHP to pop up a confirmation box before deleting data

不言
Release: 2023-03-31 12:14:02
Original
1307 people have browsed it

This article mainly introduces the simple implementation method of the pop-up confirmation box before deletion in thinkPHP. It analyzes the front-end HTML part of thinkPHP combined with js to control the pop-up box effect in the form of examples, as well as the deletion data processing function of the background controller. Friends who need it can Refer to the following

The example of this article describes the simple implementation method of popping up the confirmation box before deletion in thinkPHP. Share it with everyone for your reference, the details are as follows:

html part:

<a href="__URL__/shanchu/id/{$vo.id}" onclick=&#39;return del();&#39;>删除</a>
Copy after login

javascript part:

<script>
function del()
{
  if(confirm("确定要删除吗?"))
  {
    return true;
  }
  else
  {
    return false;
  }
}
</script>
Copy after login

Controller part:

public function shanchu()
{
  $id=$this->_request(&#39;id&#39;);
  if($id)
  {
    $user=M(&#39;user&#39;);
    $data[&#39;id&#39;]=$id;
    $rs=$user->where($data)->delete();
    if($rs)
    {
      $this->success(&#39;删除成功!&#39;);
    }
    else
    {
      $this->error(&#39;删除失败!&#39;);
    }
  }
  else
  {
    $this->error(&#39;删除失败!&#39;);
  }
}
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use ThinkPHP to integrate datatables to implement server-side paging

The above is the detailed content of How to use thinkPHP to pop up a confirmation box before deleting data. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template