本文實例講述了thinkPHP刪除前彈出確認框的簡單實現方法。分享給大家供大家參考,具體如下:
html部分:
javascript部分:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<script> function del() { if (confirm( "確定要刪除嗎?" )) { return true ; } else { return false ; } } </script> |
控制器部分:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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( '刪除失敗!' ); } } |
希望本文所述對大家基于ThinkPHP框架的PHP程序設計有所幫助。