如下代码:
function ShowTree()
{
var tree = new MzTreeView("tree"); tree.icons["property"] = "property.gif";
tree.icons["css"] = "collection.gif";
tree.icons["book"] = "book.gif";
tree.iconsExpand["book"] = "bookopen.gif";
tree.setIconPath("jsimg/"); tree.nodes["0_100"] = "text:1; data:id=100";
tree.nodes["100_200"] = "text:1; data:id=200";
tree.nodes["200_300"] = "text:1; data:id=300"; tree.setURL("default.htm");
tree.setTarget("MzMain");
document.write(tree.toString());
}现在我想从数据库中提取数据用递归来填充这个树,只有三级,我的思路是这样:把上面的代码改成一个有三个参数x,y,z的函数,分别替换100,200,300这三个数字,不知道对不对?不知道该怎么改?
tree.nodes["0_100"] = "text:1; data:id=100";
tree.nodes["100_200"] = "text:1; data:id=200";
tree.nodes["200_300"] = "text:1; data:id=300";
上面代码中的100如果用一个变量x来代替要怎么写?
这样对吗?tree.nodes["0_"x""] = "text:1; data:id=100";
function ShowTree()
{
var tree = new MzTreeView("tree"); tree.icons["property"] = "property.gif";
tree.icons["css"] = "collection.gif";
tree.icons["book"] = "book.gif";
tree.iconsExpand["book"] = "bookopen.gif";
tree.setIconPath("jsimg/"); tree.nodes["0_100"] = "text:1; data:id=100";
tree.nodes["100_200"] = "text:1; data:id=200";
tree.nodes["200_300"] = "text:1; data:id=300"; tree.setURL("default.htm");
tree.setTarget("MzMain");
document.write(tree.toString());
}现在我想从数据库中提取数据用递归来填充这个树,只有三级,我的思路是这样:把上面的代码改成一个有三个参数x,y,z的函数,分别替换100,200,300这三个数字,不知道对不对?不知道该怎么改?
tree.nodes["0_100"] = "text:1; data:id=100";
tree.nodes["100_200"] = "text:1; data:id=200";
tree.nodes["200_300"] = "text:1; data:id=300";
上面代码中的100如果用一个变量x来代替要怎么写?
这样对吗?tree.nodes["0_"x""] = "text:1; data:id=100";
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货