• MVC根据数据库形成 checkbox


    function EditImxUserRole(userintno) {
        $("#AddUserDiv").hide();
        $("#hideUserIntNo").val(userintno);

        $.post(ROOTPATH + "/Admin/GetAllUserRole", {}, function(userroleEntity) {

        }, 'json');


        $.post(ROOTPATH + "/Admin/GetImxUserRoles",
                {
                    UserIntNo: userintno
                },
                function(imxuserrolejoinentity) {
                    $("input:checkbox").attr("checked", false);
                    $.each(imxuserrolejoinentity, function(i, item) {
                        $("#" + item.UserRoleId + "").attr("checked", true);
                    })
                    $("#UserRoleDiv").show();
                }, 'json');

    }


    function UpdateRole() {
        var arrChk = $("input[@type='checkbox'][checked]");
        var id = '';
        $(arrChk).each(function() {
            id += this.id + ',';
        });

        $.post(ROOTPATH + "/Admin/UpdateUserRole",
                {
                    UserIntNo: $("#hideUserIntNo").val(),
                    Role: id
                },
                function(message) {
                    if (message.Status == true) {
                        window.location.reload();
                    }
                    else {
                        alert(alertoperation);
                        window.location.reload();
                    }

                }, 'json');
    }

    <div id="UserRoleDiv">
            <%foreach (SIL.IMX.DAL.Entities.ImxUserRole role in Model.ImxUserRoles)%>
            <%{ %>
            <input type="checkbox" id="<%=Html.Encode(role.UserRoleId) %>" name="userrole" value="<%=Html.Encode(role.UserRoleId) %>" /><%=Html.Encode(role.UserRoleName) %>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <%} %>
            <br />
            <input type="button" id="SaveRole" class="button" value="<% =Html.Resource("SaveRole.Text")%>" name="saverole" onclick="UpdateRole();" />
        </div>

  • 相关阅读:
    Python+paramiko实现绕过跳板机免密登录服务端
    ssh-keygen生成公钥私钥
    连接MySQL报 unblock with 'mysqladmin flush-hosts' 问题解决
    查询MySQL连接数
    Git常用操作命令
    cmd命令、Python脚本生成任意大小任意格式文件
    颜色渐变实现
    4月简单总结
    大佬经历读后感
    Echarts实践-实现3D地球
  • 原文地址:https://www.cnblogs.com/glj1203/p/1868017.html
Copyright © 2020-2023  润新知