用js构成一个菜单,菜单文本从数据库里读取,具体怎么做?
还有,用js怎么接收从后台代码中返回的一个泛型集合?
谢谢大家,分不多了

解决方案 »

  1.   


    function funReady(result) {
        for (var i = 0; i < result.length; i++) {
            var parentname = result[i];
            var parentid = document.getElementById('MenuContainer');
            var p = document.createElement('h4');
            p.id = i + "h4";
            var listpc = result[i].split('|');
            p.innerHTML = listpc[0];
            var hid = p.id;
            //p.attachEvent("onclick", newopen(hid));      
            parentid.appendChild(p);
            var div = document.createElement('div');
            div.id = hid + "div";
            div.style.display = "none";
            div.attachEvent("onmouseleave", divmouseout(div.id));
    //      div.attachEvent("onmouseenter", newTypeover(div.id));
            //      div.attachEvent("onmouseout", divmouseout(div.id)); onmouseleave  
            var listchild = listpc[1].split(',');
            if (listchild.length == 1) {
                if (listchild[0] == "0") {//没有子节点
                    p.innerHTML = '<a href=Pros.aspx?type=li4&ParentType=' + listpc[0] + '>' + listpc[0] + '</a>';
                    continue;
                }
            }
            //p.attachEvent("onclick", newopen(hid));onmouseover
            p.attachEvent("onmouseenter", newover(hid));      
            for (var j = 0; j < listchild.length; j++) {
                var childp = document.createElement('div');
                childp.innerHTML = '<a id=bbbb href=Pros.aspx?type=li4&ChildType=' + listchild[j] + '>' + listchild[j] + '</a>';
                childp.id = "aaa";
                childp.attachEvent("onmouseleave", divchildmouseout); 
                div.appendChild(childp);
                parentid.appendChild(div);
            }
        }
    }
    就是这段代码,在ie6里面有的菜单项没有数据
      

  2.   

    http://www.gyb369.com/Pros.aspx?type=li4就是这个地址,左边菜单项有问题,在ie6下有的菜单项没有数据,在其他浏览器里能看到
      

  3.   


     $(document).ready(function () {
                      $.ajax(
            {
                type: "GET",
                url: "Menu_Handlert.aspx?Method=Getmenu",
                data: { PageType: "GetPersonList" }, //anticache: Math.floor(Math.random() * 1000),
                beforeSend: function () { $("#treediv").html("<center><img src='Img/loading.gif' />menu is loading...</center>"); },
                success: function (data) {
                    $("#treediv").html(data);//返回的内容
                    
                },
                error: function () { $("#treediv").html("加载错误"); }
            });
                    
                  });// js菜单 代码
     //从数据库取得数据 
      StringBuilder sb = new StringBuilder();
            sb.Append(@"  <div align='center'>
                                <div id='my_menu' class='sdmenu'> ");
            //get root node
               ...
    Response.Write(sb.ToString());