Home  >  Article  >  Backend Development  >  A simple method to implement thinkPHP pop-up confirmation box before deletion, thinkphp pop-up_PHP tutorial

A simple method to implement thinkPHP pop-up confirmation box before deletion, thinkphp pop-up_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:52:04744browse

A simple implementation method for thinkPHP to pop up a confirmation box before deletion, thinkphp pops up

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127889.htmlTechArticleA simple way to implement a confirmation box that pops up before thinkPHP is deleted. ThinkPHP pops up. This article describes how thinkPHP pops up a confirmation box before deleting. Simple implementation method. Share it with everyone for your reference, with...
Statement:
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