Simple implementation of the confirmation box popped up before thinkPHP is deleted. thinkphp pops up
This example describes the simple implementation of the confirmation box popped up before thinkPHP is deleted. We will share this with you for your reference. The details are as follows:
Html section:
Copy codeThe Code is as follows: <a href = "_ URL _/shanchu/id/{$ vo. id}" onclick = 'Return del (); '> Delete </a>
Javascript section:
<Script> function del () {if (confirm ("are you sure you want to delete it? ") {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 ('deleted successfully! ');} Else {$ this-> error ('deletion failed! ') ;}} Else {$ this-> error ('deletion failed! ');}}
Supplement: The editor recommends a php formatting and formatting typographical tool on this site to help you typeset code in future PHP programming:
Php code online formatting and beautification tools:Http://tools.jb51.net/code/phpformat