无限级分类的算法
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 无限级菜单显示 </title>
</head>
<body>
<script Language= "JavaScript ">
var name=new Array();
<%
for(int i=0;i <parrStsUserList.size();i++){
pobjCp = (Cp)parrStsUserList.get(i);
out.println( "name[ "+i+ "]=new Array( ' "+pobjCp.getCpID()+ " ', ' "+pobjCp.getCpname()+ " ', ' "+pobjCp.getCpuseid()+ " '); ");
} //这是从数据库中读出的数据,下面的只是静态页面时的测试数据
%>
name[0]=new Array( '1 ', 'ggg ', '0 ');
name[1]=new Array( '2 ', 'aaa ', '1 ');
name[2]=new Array( '3 ', 'bbb ', '1 ');
name[3]=new Array( '4 ', 'ccc ', '2 ');
name[4]=new Array( '5 ', 'ddd ', '2 ');
name[5]=new Array( '6 ', 'eee ', '3 ');
name[6]=new Array( '7 ', 'fff ', '3 ');
name[7]=new Array( '8 ', 'hhh ', '2 ');
name[8]=new Array( '9 ', 'ggg1 ', '0 ');
name[9]=new Array( '10 ', 'aaa1 ', '9 ');
name[10]=new Array( '11 ', 'bbb1 ', '9 ');
name[11]=new Array( '12 ', 'ccc1 ', '11 ');
name[12]=new Array( '13 ', 'ddd1 ', '12 ');
name[13]=new Array( '14 ', 'eee1 ', '13 ');
name[14]=new Array( '15 ', 'fff1 ', '14 ');
name[15]=new Array( '16 ', 'hhh1 ', '15 ');
function check(userid,i,ddd) {
ddd= " "+ddd;
for(i=0;i <name.length;i++)
{
if(name[i][2]==userid)
{
document.write(ddd+name[i][1]+ <br/> );
check(name[i][0],0,ddd);
}
}
}
check(0,0, " <img src= '你菜单项前面的图片地址 '> ");
</script>
</body>
</html>
这个代码是前辈留下的。。现在有点问题,谁能帮我改改。。。。
------解决方案--------------------我也想知道