首页 > 代码库 > 页面内修改表格信息

页面内修改表格信息

思路:将要改的表格设成input,点击修改时removeAttr("readonly"); 

<volist name="data" id="v" >
                <?php
                if($v[pid] > 0){
                    //说明,有上级经纪人或者会员
                    $level=M("User")->where(userid=.$v[pid])->field(level)->find();
                    if($level == 0){
                        $agent="";
                        $user=$v[pid];
                    }else{
                        $agent=$v[pid];
                        $user="";
                    }
                }else{
                    //说明,没有上级经纪人或者会员
                    $agent="";
                    $user="";
                }
                if(empty($v[nowfee])){
                    $nowfee=0;
                }else{
                    $nowfee=$v[nowfee];
                }
                ?>
                    <tr class="text-c va-m tr{$v[‘userid‘]}">
                        <td><input name="id[]" type="checkbox" value=http://www.mamicode.com/"{$v.userid}"></td>
                        <td>{$v.userid}</td>
                        <td><input type="text" name="" class="broker{$v[‘userid‘]}" value=http://www.mamicode.com/"{$v.broker}" readonly /></td>
                        <td><input type="text" name="" value=http://www.mamicode.com/"<?php echo $agent; ?>" class="agent{$v[‘userid‘]}" readonly /></td>
                        <td><input type="text" name="" value=http://www.mamicode.com/"<?php echo $user; ?>" class="user{$v[‘userid‘]}" readonly /></td>
                        <td><?php if($v[level]==1){echo "初级经纪人";}elseif($v[level]==2){echo "中级经纪人";}else{echo "高级经纪人";} ?></td>
                        <td>{$v.loginname}</td>
                        <td><input type="text" name="" value=http://www.mamicode.com/"{$v.username}" class="username{$v[‘userid‘]}" readonly /></td>
                        <td>{$v.userfee}</td>
                        <td><?php echo $nowfee; ?></td>
                        <td>{$v.underfee}</td>
                        <td><input type="text" name="" value=http://www.mamicode.com/"{$v.phone}" class="phone{$v[‘userid‘]}" readonly /></td>
                        <td>{$v.opentime}</td>
                        <td class="td-manage">
                        <a style="text-decoration:none" class="ml-5" onclick="ajaxInfo_under({$v[‘userid‘]})" href=http://www.mamicode.com/"javascript:;" title="查看下级"><i class="Hui-iconfont">&#xe63d;</i></a>&nbsp;
                        <a style="text-decoration:none" class="ml-5" onclick="ajaxInfo_under({$v[‘userid‘]})" href=http://www.mamicode.com/"javascript:;" title="写留言"><i class="Hui-iconfont">&#xe6eb;</i></a>&nbsp;
                        <a style="text-decoration:none" class="ml-5 bianji bianji{$v[‘userid‘]}" href=http://www.mamicode.com/"javascript:viod(0)"  title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>&nbsp;
                        <a style="" class="ml-5 baocun baocun{$v[‘userid‘]}" href=http://www.mamicode.com/"javascript:viod(0)" onclick="submit()" title="保存">保存</a>
                        <a style="" class="ml-5 quxiao quxiao{$v[‘userid‘]}" href=http://www.mamicode.com/"javascript:viod(0)"  title="取消">取消</a>
                        </td>

                    </tr>
</volist>
<script>
$(".baocun").hide();
$(".quxiao").hide();
    var num ;
$(".bianji").click(function(){
    $(this).nextAll().show();    
    $(this).hide();
    $(this).parent().prevAll().find("input").removeAttr("readonly");
});

$(".baocun").click(function(){
    $(this).prev().show();
    $(this).next().hide();
    $(this).hide();
    $(this).parent().prevAll().find("input").prop("readonly","true");
});
$(".quxiao").click(function(){
    var num = $(this).parent().prevAll().find("input").val();
    $.ajax({
        type:"get",
        url:"/Admin/Team/info_edit",
        data:"num="+num,
        dataType:"json",
        success:function(res){
            $(".broker"+num).val(res.broker);
            $(".agent"+num).val(res.agent);
            $(".user"+num).val(res.user);
            $(".username"+num).val(res.username);
            $(".phone"+num).val(res.phone);
            $(".tr"+num).find("input").prop("readonly","true");
            $(".quxiao"+num).hide();
            $(".baocun"+num).hide();
            $(".bianji"+num).show();

        }
    })
});
</script>
 

 

页面内修改表格信息