怎么不能正常显示呀,你是对这个函数没有调用呀,当然没有反应了呀,对了你看看下面这个就是你的代码在我的机了上输出fibona的,我只加上php标志而已。不知道楼主的主要问题是什么。<?
function fenlei(){
global $prefix,$dbi,$r,$m,$s,$mtype,$stype;$rsel;
$count;
?>
<script language = "JavaScript">var onecount1;
onecount1=0;
rootcat = new Array();
        <?php 
$count=0;
$rsel="select distinct r,mtype,m from ".$prefix."_type order by m asc";
$result=mysql_query($rsel,$dbi);
while($row=mysql_fetch_array($result)){
?>
rootcat[<?php echo $count ?>] = new Array("<?php echo "document.write('trim($row[r])')"?>","<?php echo trim($row[mtype])?>","<?php echo trim($row[m])?>");
        <?php 
$count++;
}
?>

onecount1=<?php echo $count?>;var onecount2;
onecount2=0;
subcat = new Array();
        <?php 
$count = 0;
$rsel="select distinct m,stype,s from ".$prefix."_type order by s asc";
$result=mysql_query($rsel,$dbi);
while($row=mysql_fetch_array($result)){
?>

subcat[<?php echo $count ?>] = new Array("<?php echo trim($row[m])?>","<?php echo trim($row[stype])?>","<?php echo trim($row[s])?>");
        <?php 
$count++;
}
?>
onecount2=<?php echo $count?>;
function changem(locationid)
    {
    document.txForm.m.length = 0;     var locationid=locationid;
    var i;
    for (i=0;i < onecount1; i++)
        {
            if (rootcat[i][0] == locationid)
            { 
                document.txForm.m.options[document.txForm.m.length] = new Option(rootcat[i][1], rootcat[i][2]);
            }        
        }
        
    }function changes(locationid)
    {
    document.txForm.s.length = 0;     var locationid=locationid;
    var i;
    for (i=0;i < onecount2; i++)
        {
            if (subcat[i][0] == locationid)
            { 
                document.txForm.s.options[document.txForm.s.length] = new Option(subcat[i][1], subcat[i][2]);
            }        
        }
        
    }    
    
</script>
<?
$selo;
$rsel="select distinct r,rtype from ".$prefix."_type order by r asc";
$result=mysql_query($rsel,$dbi);
if(!$row=mysql_fetch_array($result)){
  echo "请先添加栏目。";
  }
else{
  echo "<select name='r' onChange='changem(document.txForm.r.options[document.txForm.r.selectedIndex].value)'>";
  unset($result);
  $result=mysql_query($rsel,$dbi);
  while($row=mysql_fetch_array($result)){
    if($row[r]==$r){
      $selo="selected";
  }
    else{
      $selo="";
 }
   echo "<option ".$selo." value='".trim($row[r])."'>".trim($row[rtype])."</option>";
  }
 }
echo "</select>";
echo "<select name='m' onChange='changes(document.txForm.m.options[document.txForm.m.selectedIndex].value)'>";                
if($mtype<>""){
  echo "<option selected value=".$m.">".$mtype."</option>";
  }
else{
  echo "<option selected value=>请选栏目</option>";
  }
echo "</select>";
echo "<select name='s'>";
if($stype<>""){
  echo "<option selected value=".$s.">".$stype."</option>";
  }
else{
  echo "<option selected value=>请选栏目</option>";
  }
 
echo "</select><font color=red>**</font>";} //function end
?>
asdgasdgjkl;asdgklj;

解决方案 »

  1.   

    <?
    function fenlei(){
    global $prefix,$dbi,$r,$m,$s,$mtype,$stype;$rsel;
    $count;
    ?>
    <script language = "JavaScript">var onecount1;
    onecount1=0;
    rootcat = new Array();
            <?php 
    $count=0;
    $rsel="select distinct r,mtype,m from ".$prefix."_type order by m asc";
    $result=mysql_query($rsel,$dbi);
    while($row=mysql_fetch_array($result)){
    ?>
    rootcat[<?php echo $count ?>] = new Array("<?php echo "document.write('trim($row[r])')"?>","<?php echo trim($row[mtype])?>","<?php echo trim($row[m])?>");
            <?php 
    $count++;
    }
    ?>

    onecount1=<?php echo $count?>;var onecount2;
    onecount2=0;
    subcat = new Array();
            <?php 
    $count = 0;
    $rsel="select distinct m,stype,s from ".$prefix."_type order by s asc";
    $result=mysql_query($rsel,$dbi);
    while($row=mysql_fetch_array($result)){
    ?>

    subcat[<?php echo $count ?>] = new Array("<?php echo trim($row[m])?>","<?php echo trim($row[stype])?>","<?php echo trim($row[s])?>");
            <?php 
    $count++;
    }
    ?>
    onecount2=<?php echo $count?>;
    function changem(locationid)
        {
        document.txForm.m.length = 0;     var locationid=locationid;
        var i;
        for (i=0;i < onecount1; i++)
            {
                if (rootcat[i][0] == locationid)
                { 
                    document.txForm.m.options[document.txForm.m.length] = new Option(rootcat[i][1], rootcat[i][2]);
                }        
            }
            
        }function changes(locationid)
        {
        document.txForm.s.length = 0;     var locationid=locationid;
        var i;
        for (i=0;i < onecount2; i++)
            {
                if (subcat[i][0] == locationid)
                { 
                    document.txForm.s.options[document.txForm.s.length] = new Option(subcat[i][1], subcat[i][2]);
                }        
            }
            
        }    
        
    </script>
    <?
    $selo;
    $rsel="select distinct r,rtype from ".$prefix."_type order by r asc";
    $result=mysql_query($rsel,$dbi);
    if(!$row=mysql_fetch_array($result)){
      echo "请先添加栏目。";
      }
    else{
      echo "<select name='r' onChange='changem(document.txForm.r.options[document.txForm.r.selectedIndex].value)'>";
      unset($result);
      $result=mysql_query($rsel,$dbi);
      while($row=mysql_fetch_array($result)){
        if($row[r]==$r){
          $selo="selected";
      }
        else{
          $selo="";
     }
       echo "<option ".$selo." value='".trim($row[r])."'>".trim($row[rtype])."</option>";
      }
     }
    echo "</select>";
    echo "<select name='m' onChange='changes(document.txForm.m.options[document.txForm.m.selectedIndex].value)'>";                
    if($mtype<>""){
      echo "<option selected value=".$m.">".$mtype."</option>";
      }
    else{
      echo "<option selected value=>请选栏目</option>";
      }
    echo "</select>";
    echo "<select name='s'>";
    if($stype<>""){
      echo "<option selected value=".$s.">".$stype."</option>";
      }
    else{
      echo "<option selected value=>请选栏目</option>";
      }
     
    echo "</select><font color=red>**</font>";} //function end
    ?>
    fibona
      

  2.   

    function fenlei(){
    global $prefix,$dbi,$r,$m,$s,$mtype,$stype;$rsel;
    $count;?>
    这是什么意思》???
      

  3.   

    to  ice_berg16(寻梦的稻草人),当然是没有贴全了,要不就出错了!
      

  4.   

    我这是PHP文件中的一部分,调用部分我没写出,只写出了它的函数部分,这个函数的功能是这样,我设置了两个"根栏目",比如一个是"文学作品",一个是"技术文章",然后在文学作品下分主根目"现代作品",在现代作品下分一个子栏目"诗歌",在另一个根栏目"技术文章"下设一个主根目"电脑维修"下设子栏目"硬件部分",这个函数的功能是显示出根栏目,主栏目,子栏目的名称,当我改变根栏目名时,主根目也要做相应的变代(即与它的根栏目相对应)但现在只能显示根栏目名,改变根栏目时它的下级为空,我不知问题出在何处,特此求教
      

  5.   

    这个文件本来是ASP的代码,我把其中的ASP部分改成了PHP,其它的没动,结果就不能正常显示了
      

  6.   

    这个文件本来是ASP的代码,我把其中的ASP部分改成了PHP,其它的没动,结果就不能正常显示了