更新且重置

                                            进行刷新
<script language="JavaScript">
        function fresh(){
            window.location.reload();
        }
    </script>
    
    $(fresh());
---------------------------------------------------------------------------------------------------------------------------------------------------
                                            进行刷新
 $("#order").bootstrapTable('refresh');
---------------------------------------------------------------------------------------------------------------------------------------------------
                                            jsp项目路径
-<%--<%--%>
<%--    String path = request.getContextPath();--%>
<%--    String basePath = request.getScheme()+"://"+request.getServerName()+--%>
<%--            ":"+request.getServerPort()+path+"/";--%>
<%--%>--%>

  <%--url:<%=basePath%><%=path%>+"member_add",--%>
--------------------------------------------------------------------------------------------------------------------------------------------------
                                            重置
 function resetting() {
        $.ajax({
            member_card:$("#member_card").val().focus(),
            member_card:$("#name").val().focus(),
            member_card:$("#phone").val().focus(),
            member_card:$("#idcard").val().focus(),
            member_card:$("#address").val().focus(),
            member_card:$("#style").val().focus(),
        })
    }

                                            重置
function resetting() {
            $.ajax({
                member_id:$("#card2").val(""),
                member_id: $("#card2").val(""),
                member_id: $("#name").val(""),
                member_id:$("#member_id").val(""),
                
            })
        }

--------------------------------------------------------------------------------------------------------------------------------------------------
                                            删除
function del(mid){
        $.ajax({
            type:'post',
            url:'member_delete',
            data:{mid:mid},
            success:function (data){
                if (data=="success"){
                    $("#myModal").modal("toggle");
                }
                $("#order").bootstrapTable('refresh');
            }
        })
    }
--------------------------------------------------------------------------------------------------------------------------------------------------
                                            更改前让数据放入文本框里
function update(mid){
        $.ajax({
            type:'post',
            url:'query',
            data:{mid:mid},
            dataType:'json',
            success:function (json){
                $("#member_card").val(json[0].member_card);
                $("#name").val(json[0].name);
                $("#phone").val(json[0].phone);
                $("#idcard").val(json[0].idcard);
                $("#address").val(json[0].address);
            }
        })
    }
--------------------------------------------------------------------------------------------------------------------------------------------------
                                            更改传参数

$("#update").click(
        function updates() {
        $.ajax({
            type:"post",
            url:'member_update',
            data:{
                member_card:$("#member_card").val(),
                name:$("#name").val(),
                phone:$("#phone").val(),
                idcard:$("#idcard").val(),
                address:$("#address").val(),
            },
            success:function (data){
                if (data=="success"){
                  alert("更改成功");
                }
                $(fresh());
            }
        })
    })

















---------------------------------------------------------------------------------------------------------------------------------------------------
                                                分页
$(tab());
    function tab(){
        $("#order").bootstrapTable({
            url:'member_list',
            dataField: 'rows',
            striped: true,
            toolbar:'#toolbar',
            toolbarAlign: 'right',
            pagination: true,                   //是否显示分页(*)
            pageNumber: 1,                  //初始化加载第一页,默认第一页
            pageSize: 5,                  //每页的记录行数(*)
            pageList: [5, 10, 20],      //可供选择的每页的行数(*)
            queryParamsType: 'limit',     //默认值为 'limit' ,在默认情况下 传给服务端的参数为:offset,limit,sort
            sidePagination: "server",   //设置服务器端分页
            columns: [{
                checkbox: true
            }, {
                field: 'mid',
                title: '序号'
            }, {
                field: 'member_card',
                title: '会员编号'
            }, {
                field: 'name',
                title: '会员姓名'
            }, {
                field: 'phone',
                title: '联系电话'
            }, {
                field: 'idcard',
                title: '身份证号'
            }, {
                field: 'mtime',
                title: '办理时间'
            },{
                field: 'address',
                title: '家庭住址'
            },{
                field: 'style',
                title: '会员类型'
            },{
                field: 'state',
                title: '状态',
                formatter:function(value){
                    switch (value) {
                        case "1" :
                            return "<span class='label label-info'>已激活</span>";
                        case "0" :
                            return "<span class='label label-danger'>未激活</span>";
                    }
                }
            },{
                field: 'operate',
                title: '操作',
                formatter:function (value,row,index){
                    var result = "";
                    result += '<button id="delete" data-toggle="modal" data-target="#myModal_delete" class="btn btn-danger" onclick="del('+row.mid+')" style="margin-left:10px;">删除</button>';
                    result += '<button id="update" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal_update"  onclick="update('+row.mid+')" style="margin-left:30px;">修改</button>';
                    return result;
                }
            } ]
        });
    }

posted @ 2021-03-03 02:17  梦已然清空  阅读(38)  评论(0编辑  收藏  举报