使用梅花雪的树形控件出错,谁帮我看一看JS的代码哪有问题
我先定义了一个JS函数:
<script language= "JavaScript ">
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:´úÂëʾÀý; data:id=100 ";
tree.nodes[ "100_307 "] = "text:¶ÔÏó; data:id=407 ";
tree.nodes[ "100_306 "] = "text:·½·¨; data:id=406 ";
tree.nodes[ "100_308 "] = "text:ÔËËã·û; data:id=408 ";
tree.nodes[ "100_309 "] = "text:ÊôÐÔ; data:id=409 ";
tree.setURL( "default.htm ");
tree.setTarget( "MzMain ");
document.write(tree.toString()); //Òà¿ÉÓÃ obj.innerHTML = tree.toString();
}
</script>
然后在PHP代码中调用:
<?
$js = ' <script language= "JavaScript "> ShowTree(); </script> ';
echo $js;
?>
如果JS的那段代码不做成函数,不用PHP调用,显示树形是没有问题的,现在就有问题了:二级显示不出来,只能显示一级的,而且页面的错误:“tree”未定义
请问大家告诉我是怎么回事?我这样做的目的是试着从数据库中读取数据填充这个树
------解决方案--------------------帮顶
------解决方案-------------------- <script language= "JavaScript "> ShowTree(); </script> ';位置有问题吧?
放到页面的最后
------解决方案--------------------不会!
学习,学习!