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:
##Copy code The code is as follows:
Deletejavascript part:
<script> function del() { if(confirm("确定要删除吗?")) { return true; } else { return false; } } </script>
Controller part:
public function shanchu() { $id=$this->_request('id'); if($id) { $user=M('user'); $data['id']=$id; $rs=$user->where($data)->delete(); if($rs) { $this->success('删除成功!'); } else { $this->error('删除失败!'); } } else { $this->error('删除失败!'); } }
Example details how to convert html word to and from PHP
##
The above is the detailed content of A simple implementation method of popping up a confirmation box before deletion in thinkPHP. For more information, please follow other related articles on the PHP Chinese website!