tp_window.onload+相应操作

From , 3 Years ago, written in PHP, viewed 54 times.
URL https://pastebin.vip/view/f24ad6f7
  1. <script>
  2.             window.onload=function(){
  3.                 if(<{$data.sex}>==0){
  4.                     document.getElementsByName('sex')[1].checked='checked';
  5.                 }else{
  6.                     document.getElementsByName('sex')[0].checked='checked';
  7.                 }
  8.             }
  9.         </script>
  10.  
  11. <?php
  12.     class UserAction extends Action{
  13.         public function index(){
  14.             $m=M('User');
  15.             $arr=$m->select();
  16.             //var_dump($arr);
  17.             $this->assign('data',$arr);
  18.             $this->display();
  19.         }
  20.         public function del(){
  21.             $m=M('User');
  22.             $id=$_GET['id'];
  23.             $count=$m->delete($id);
  24.             if($count>0){
  25.                 $this->success('数据删除成功');
  26.             }else{
  27.                 $this->error('数据删除失败');
  28.             }
  29.         }
  30.         /*
  31.          *    显示修改页面
  32.          * */
  33.         public function modify(){
  34.             $id=$_GET['id'];
  35.             $m=M('User');
  36.             $arr=$m->find($id);
  37.             $this->assign('data',$arr);
  38.             $this->display();
  39.         }
  40.         public function update(){
  41.             $m=M('User');
  42.             $data['id']=$_POST['id'];
  43.             $data['username']=$_POST['username'];
  44.             $data['sex']=$_POST['sex'];
  45.             $count=$m->save($data);
  46.             if($count>0){
  47.                 $this->success('数据修改成功','index');
  48.             }else{
  49.                 $this->error('数据修改失败');
  50.             }
  51.         }
  52.         /*
  53.          * 添加页面
  54.          * */
  55.         public function add(){
  56.             $this->display();
  57.         }
  58.         public function create(){
  59.             $m=M('User');
  60.             $m->username=$_POST['username'];
  61.             $m->sex=$_POST['sex'];
  62.             $idNum=$m->add();
  63.             if($idNum>0){
  64.                 $this->success('数据添加成功','index');
  65.             }else{
  66.                 $this->error('数据添加失败');
  67.             }
  68.         }
  69.     }
  70. ?>
  71. -------------------------------------------------------------------
  72.  
  73. <button onclick="jump()">添加用户</button>
  74.  
  75. <script>
  76.             function jump(){
  77.                 window.location="/thinkphp/index.php/User/add";
  78.             }
  79.         </script>
  80.  

Reply to "tp_window.onload+相应操作"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website