LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

js基础:Javascript实现自动无限级关联下拉菜单

admin
2010年8月18日 9:58 本文热度 3327

<html>
<head>
<title>级联下拉菜单</title>
<meta http-equiv = "Content-Type" counter = "text/html;charset = gb2312">
<script>...
var nMaxLength = 0;
function init(obj)
...{
   
    var hasChild = false;
    var nodes = document.getElementsByTagName('p');
    var selectobj;
    var pid = (obj==undefined) ? 0 : parseInt(obj.value);   
    var selectobj = document.createElement('select');
    selectobj.setAttribute('name','select_' + nMaxLength);
    selectobj.onchange = function()
    ...{
        var sels = document.getElementsByTagName('select');
        for(var j=sels.length-1;j>0;j--)
        ...{                 if(sels[j]==this)
            ...{
                break;
            }
            nMaxLength--;
            document.getElementById('div1').removeChild(sels[j]);
        }   
        init(this);
    }
    for(var i=0;i<nodes.length;i++)
    ...{
        var thispid = parseInt(nodes[i].getAttribute('pid'));
        var id = parseInt(nodes[i].getAttribute('id'));
        var n = nodes[i].getAttribute('n');
        if(thispid == pid)
        ...{
            var opt = document.createElement('option');
            opt.setAttribute('value',id);
            opt.innerText = n;
            selectobj.appendChild(opt);
            hasChild = true;
        }

;   }           
    if(hasChild)
    ...{
        nMaxLength++;
        document.getElementById('div1').appendChild(selectobj);
        init(selectobj);
    }   
}

function getMaxLength()
...{
    document.forms[0].maxLength.value = nMaxLength;
    return true;
}

</script>
</head>
<body onload = "init();">
<form action ="" method="post" onsubmit="return getMaxLength();">
<div id="div1">
<p n='product' id='0' pid='-1' /><p n='art' id='1' pid='0' /><p n='english' id='2' pid='0' /><p n='game' id='3' pid='0' />
<p n='math' id='4' pid='0' /><p n='natural' id='5' pid='0' /><p n='operate' id='6' pid='0' />
<p n='poem' id='7' pid='0' /><p n='science' id='8' pid='0' /><p n='high' id='11' pid='1' />
<p n='low' id='12' pid='1' /><p n='middle' id='13' pid='1' /><p n='abc' id='21' pid='2' />
<p n='number' id='22' pid='2' /><p n='song' id='23' pid='2' /><p n='story' id='24' pid='2' />
<p n='talk' id='25' pid='2' /><p n='listen' id='251' pid='25' />
<p n='read' id='252' pid='25' /><p n='word' id='253' pid='25' />
<p n='write' id='254' pid='25' /><p n='test' id='44' pid='1' /><p n='high' id='41' pid='4' />
</div>
<input type="hidden" name="maxLength" value="">
</form>
</body>
</html>


该文章在 2010/8/18 9:58:08 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved