求助关于二级连动菜单问题

求助关于二级连动菜单问题

二级连动菜单小类不能取到值大家帮忙看看代码 哪里有错误 急死我了弄了一天了

<html>
<head>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<?php
require('../conn.php');
$sql = "select * from smallclass";
$result = mysql_query( $sql );
$count = 0;
while($res = mysql_fetch_row($result)){
?>
subcat[<?=$count?>] = new Array("<?=$res[0]?>","<?=$res[1]?>","<?=$res[2]?>");
<?
$count++;
}
echo "onecount=$count;";
?>
//联动函数
function changelocation(locationid)
    {
    document.myform.ctype.length = 0;
    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[2] == locationid)
            {
       //var newOption1=new Option(subcat[1], subcat[0]);
               // document.all.ctype.add(newOption1);
                document.myform.ctype.options[document.myform.ctype.length] = new Option(subcat

[1], subcat[0]);
            }        
        }
        
    }   
</script>
</head>
<body>
<form method="post" name="myform" action="">
<table border="1" cellpadding="0" cellpscing="0" width="400" aling="center">
<tr>
<td>标题</td>
<td><input type="text" name="titile" ></td>
</tr>
<tr>
<td>分类</td>
<td>
<select name="type" onChange="changelocation(document.myform.type.options

[document.myform.type.selectedIndex].value)" size="1">
<option selected value="">请指定主分类</option>
        
<?
   $sql = "select * from bigclass";
   $result = mysql_query( $sql );
   while($res = mysql_fetch_row($result)){
?>
    <option value="<? echo $res[0]; ?>"><? echo $res[1]; ?></option>
  <? } ?>
        
       </select>
   
    <select name="ctype" >                  
        <option selected value="">请指定小分类</option>

    </select>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="确定"></td>
</tr>
</table>
</form>
</body>
</html>
如履薄冰