注册 登录
编程论坛 ASP技术论坛

请教二级联动菜单的回显问题

liujiangmc 发布于 2008-05-06 14:14, 777 次点击
在修改新闻页面时,要用到二级菜单回显,大类菜单我可以正确回显,但为什么小类菜单只显示一个“请选择”其他的什么都不能显示呢,必须在大类里选择其他项目后小类菜单才有相应的内容?请指教
这是相关代码:
<SCRIPT language = "javascript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0
        do while not Recordset2.eof
        %>
subcat[<%=count%>] = new Array("<%= trim(Recordset2("n_s_type"))%>","<%= trim(Recordset2("n_b_ID"))%>","<%= trim(Recordset2("n_s_ID"))%>");
        <%
        count = count + 1
        Recordset2.movenext
        loop
        %>
onecount=<%=count%>;

 

function change2(locationid2)
    {
    document.form2.n_s_type.length = 0;

    var locationid2=locationid2;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid2)
            {
                document.form2.n_s_type.options[document.form2.n_s_type.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }   
</SCRIPT>
.....
.....
<select name="n_b_type" id="n_b_type" onChange="change2(document.form2.n_b_type.options[document.form2.n_b_type.selectedIndex].value)">
      
          <% do while not Recordset1.eof  %>
          <option value="<%=(Recordset1("n_b_ID").Value)%>" <% if Recordset1.Fields.Item("n_b_ID")=Recordset3.Fields.Item("n_b_ID") then response.Write("selected") end if%>  ><%=(Recordset1.Fields.Item("n_b_type").Value)%></option>
          <%
          Recordset1.movenext
           loop
        
       %>

        </select>
...
...
<select name="n_s_type" id="n_s_type">
        <option>----请选择----</option>
        <% do while not Recordset2.eof  %>
          <option value="<%=(Recordset2("n_s_ID").Value)%>" selected <% if Recordset3.Fields.Item("n_b_ID")=Recordset2.Fields.Item("n_b_ID") then response.Write("selected") end if%>  ><%=(Recordset2.Fields.Item("n_s_type").Value)%></option>
          <%
          Recordset2.movenext
           loop
        
       %>
      </select>
0 回复
1