Home > Article > Backend Development > A simple method to implement thinkPHP pop-up confirmation box before deletion, thinkphp pop-up_PHP tutorial
This article describes an example of a simple implementation method for thinkPHP to pop up a confirmation box before deletion. Share it with everyone for your reference, the details are as follows:
html part:
Copy code The code is as follows:d8e5d7c4676db2b83b1f154f01927a64 Delete5db79b134e9f6b82c0b36e0489ee08ed
javascript 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('删除失败!'); } }
Supplement: The editor here recommends a PHP formatting and beautifying typesetting tool on this website to help you code typesetting in future PHP programming:
PHP code online formatting and beautification tool: http://tools.jb51.net/code/phpformat
Readers who are interested in more thinkPHP-related content can check out the special topics on this site: "ThinkPHP Getting Started Tutorial", "ThinkPHP Common Methods Summary", "Smarty Template Basic Tutorial" and "PHP Template Technology Summary".
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.