日期:2014-05-19  浏览次数:20408 次

使用梅花雪的树形控件出错,谁帮我看一看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 ";   //&Otilde;&sup1;&iquest;&ordf;&Ecirc;±&para;&Ocirc;&Oacute;&brvbar;&micro;&Auml;&Iacute;&frac14;&AElig;&not;
    tree.setIconPath( "jsimg/ ");   //&iquest;&Eacute;&Oacute;&Atilde;&Iuml;à&para;&Ocirc;&Acirc;·&frac34;&para;

    tree.nodes[ "0_100 "]   =   "text:&acute;ú&Acirc;&euml;&Ecirc;&frac34;&Agrave;&yacute;;   data:id=100 ";
    tree.nodes[ "100_307 "]   =   "text:&para;&Ocirc;&Iuml;ó;   data:id=407 ";
    tree.nodes[ "100_306 "]   =   "text:·&frac12;·¨;   data:id=406 ";
    tree.nodes[ "100_308 "]   =   "text:&Ocirc;&Euml;&Euml;&atilde;·&ucirc;;   data:id=408 ";
    tree.nodes[ "100_309 "]   =   "text:&Ecirc;&ocirc;&ETH;&Ocirc;;   data:id=409 ";

    tree.setURL( "default.htm ");
    tree.setTarget( "MzMain ");
    document.write(tree.toString());         //&Ograve;à&iquest;&Eacute;&Oacute;&Atilde;   obj.innerHTML   =   tree.toString();
    }
</script>

然后在PHP代码中调用:
<?
$js   =   ' <script   language= "JavaScript "> ShowTree(); </script> ';
echo   $js;
?>

如果JS的那段代码不做成函数,不用PHP调用,显示树形是没有问题的,现在就有问题了:二级显示不出来,只能显示一级的,而且页面的错误:“tree”未定义

请问大家告诉我是怎么回事?我这样做的目的是试着从数据库中读取数据填充这个树

------解决方案--------------------
帮顶
------解决方案--------------------
<script language= "JavaScript "> ShowTree(); </script> ';位置有问题吧?
放到页面的最后
------解决方案--------------------
不会!
学习,学习!