文章出處

2014-02-16

 

控制器中的代碼:

    public function actionUpdown(){
        //print_r($_POST);die();
        if(Buser::model()->updateByPk($_POST['hideid'], array('status'=>$_POST['hide']))){
            echo 1;
        }else {
            echo 0;
        }

    }

view 視圖中的代碼:

<td class="edit" width="150">
                <?php if($v->status==0):?>
                    <a href="javascript:void(0)" id="down" class="a" data="1" hideid="<?php echo $v->id;?>">激活</a>
                <?php elseif ($v->status==1):?>
                    <a href="javascript:void(0)" id="up" class="b" data="0" hideid="<?php echo $v->id;?>">禁用</a>
                <?php endif;?>
</td>
<script>
    $(function(){
        $("#up,#down").live('click',function(){
            var _this=$(this);
            var udmsg=['賬號可用','賬號不可用','up','down'];
            var udhtml=['禁用','激活'];
            var hide=$(this).attr("data");
            var hideid=$(this).attr("hideid");
            $.post("<?php echo $this->createUrl('/buser/updown');?>",{hideid:hideid,hide:hide},function(msg){
                if(msg==1){
                    _this.html(udhtml[hide]);
                    var data=Math.abs(Number(hide)-1);
                    _this.attr('data',data);
                    _this.parent().prev().children().removeClass();
                    var upclass=Number(hide)+2;
                    _this.parent().prev().children().addClass(udmsg[upclass]);
                    _this.parent().prev().children().html(udmsg[hide]);
                    window.location.reload();
                }else{
                    alert('修改失敗!');
                }
            });
        });
</script>

 


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()