ASP二级联动菜单

作者在 2007-03-06 21:36:00 发布以下内容

js部分

<script language = "JavaScript">
sall=new Array();
<%
Dim i
i=0
set rs=server.createobject("adodb.recordset")
sql="select * from t_smallclass"
rs.open sql,conn,1,1
do while not rs.eof
%>
sall[<%=i%>]=new Array("<%=rs("classname")%>","<%=rs("c_id")%>","<%=rs("id")%>");
<%
i=i+1
rs.movenext
loop
rs.close
set rs=nothing
%>
function changeselect(selvalue) 
   {
      document.form1.typeid.length=0; 
      var selvalue=selvalue;
      var i;
      for(i=0;i<sall.length;i++)
{
    if(sall[1]==selvalue)
      {
  var newOption1=new Option(sall[0],sall[2]);
document.all.typeid.add(newOption1);
}
}
}

function Changesel(){
window.form1.taskclass.value=window.form1.sortid.options[window.form1.sortid.selectedIndex].text +">>" + window.form1.typeid.options[window.form1.typeid.selectedIndex].text;
}
</script>

 

asp部分

 <form id="form1" name="form1" method="post" action="addtask_2.asp">
                                                <p>
                                                  <select name="sortid" size="1" class="blueborder" onchange="changeselect(document.form1.sortid.options[document.form1.sortid.selectedIndex].value)">
                                                    <option selected="selected" value="">--请选择任务大类--</option>
                                                    <%
set rs1=server.createobject("adodb.recordset")
sql1="select * from t_taskbigclass"
rs1.open sql1,conn,1,1
do while not rs1.eof
response.write "<option value='"&rs1("c_id")&"'>"&rs1("c_title")&"</option>"&chr(13)+chr(10)
rs1.movenext
loop
rs1.close
%>
                                                  </select>
                                                  <select name="typeid" class="blueborder" onFocus="return Changesel()">
                                                    <option selected="selected" value=

技术随笔 | 阅读 18099 次
文章评论,共0条
游客请输入验证码