zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    spring-boot4
    spring-boot3代码
    spring-boot3
    spring-boot2代码
    spring-boot2
    Java Socket编程
    eclipse项目中.classpath文件详解
    spring-boot1
    ASCII 在线转换器
    如何在Android开发中让你的代码更有效率
  • 原文地址:https://www.cnblogs.com/glj1203/p/1868017.html
Copyright © 2011-2022 走看看