标签:java   html   js   数据   src   id   t   el   ui   at   doc   

<script type="text/javascript">
        $(function () {
            var allmenus = "[{\"ID\":\"19000031\",\"name\":\"门禁\",\"icon\":\"Images/考核.png\",\"URL\":\"MeetingCenter/AddMeetInfo.aspx\"},{\"ID\":\"19000032\",\"name\":\"消费\",\"icon\":\"Images/会议查询.png\",\"URL\":\"MeetingCenter/MeetingInfoManage.aspx\"},{\"ID\":\"19000011\",\"name\":\"公共\",\"icon\":\"Images/人员分组管理.png\",\"URL\":\"MeetingCenter/MeetCustGroupInfo.aspx\"},{\"ID\":\"19000040\",\"name\":\"通用\",\"icon\":\"Images/会议综合报表.png\",\"URL\":\"MeetingCenter/MeetingHandManage.aspx\"},{\"ID\":\"19000012\",\"name\":\"平台\",\"icon\":\"Images/会议室管理.png\",\"URL\":\"MeetingCenter/MeetingPlace.aspx\"}]"; // = <=userMenus>; 需要是jason数据 
            allmenus = eval(allmenus);


            if (allmenus != null) {
                for (var i = 0; i < allmenus.length; i++) {
                    var item = allmenus[i];
                    if (item.URL == "") {
                        var innerHTML = "<li><a href=\"javascript:void(0)\ " + item.name + "</a><ul id=\"ul" + item.ID + "\"></ul></li>";
                    }
                    else {
                        var innerHTML = "<li><a href=\"javascript:void(0)\"  onclick=\"getmenubyname(‘" + item.URL + "?" + "‘,‘" + item.name + "‘,‘" + item.ID + "‘)\">" + item.name + "</a><ul id=\"ul" + item.ID + "\"></ul></li>";

                    }
                    $("#menuComponent").html($("#menuComponent").html() + innerHTML);

                }
            }

        });

        function getmenubyname(url, name, menuid) {
            $("#custmenu").empty();
            var objnew;
            if (name == "门禁") {
                objnew = "[{\"menuid\":\"19000031\",\"menuname\":\"新建会议\",\"icon\":\"Images/新建会议.png\",\"navlink\":\"MeetingCenter/AddMeetInfo.aspx\"},{\"menuid\":\"19000032\",\"menuname\":\"会议维护\",\"icon\":\"Images/会议查询.png\",\"navlink\":\"MeetingCenter/MeetingInfoManage.aspx\"}]";
            }
            else if (name == "消费") {
                objnew = "[{\"menuid\":\"19000011\",\"menuname\":\"人员组管理\",\"icon\":\"Images/人员分组管理.png\",\"navlink\":\"MeetingCenter/MeetCustGroupInfo.aspx\"},{\"menuid\":\"19000040\",\"menuname\":\"补签/请假\",\"icon\":\"Images/会议综合报表.png\",\"navlink\":\"MeetingCenter/MeetingHandManage.aspx\"}]";
            }
            else if (name == "通用") {
                objnew = "[{\"menuid\":\"19000012\",\"menuname\":\"会议室管理\",\"icon\":\"Images/会议室管理.png\",\"navlink\":\"MeetingCenter/MeetingPlace.aspx\"}]";
            }
            else {
                objnew = "[{\"menuid\":\"19000012\",\"menuname\":\"测试菜单\",\"icon\":\"Images/会议室管理.png\",\"navlink\":\"MeetingCenter/MeetingPlace.aspx\"}]";
            }
            objnew = eval(objnew);
            var totalnum = objnew.length; //获取返回数据条数,用于更新ul区域宽度                 
            var s = document.getElementById(‘custmenu‘);
            for (var i = 0; i < totalnum; i++) {
                var li = document.createElement("li");
                var str = "<a href=\"javascripst:void(0)\" onclick=\"changeCurrentUrl(‘" + objnew[i].navlink.replace(new RegExp(/(\\)/g), ‘\\\\‘) + "‘,‘" + objnew[i].menuname + "‘,‘‘)\"><img src=‘" + objnew[i].icon + "‘ border=‘0‘ /><span>" + objnew[i].menuname + "</span></a>";
                li.innerHTML = str;
                s.appendChild(li);
            }
        }

        function changeCurrentUrl(url, name, menuid) {
            $("#currentLocation").html(name);
            document.getElementById("frame_content").src = url;
        }
    </script>

测试 多级联动js,布布扣,bubuko.com

测试 多级联动js

标签:java   html   js   数据   src   id   t   el   ui   at   doc   

原文:http://www.cnblogs.com/jojy/p/3654760.html