网页设计asp联动三级菜单

19622012-04-17

[codes]

<!--#include file="Conn.asp"-->

<%

sql = "select * from smallclass order by smallclassid asc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
  <%
  count = 0
  do while not rs.eof 
  %>
subcat[<%=count%>] = new Array("<%= trim(rs("smallclassname"))%>","<%= trim(rs("bigclassname"))%>","<%= trim(rs("smallclassname"))%>");
  <%
  count = count + 1
  rs.movenext
  loop
  rs.close
  set rs=nothing
  %>
onecount=<%=count%>;

function changelocation(bigclassname)
  {
  document.myform.smallclassname.length = 0; 

  var bigclassname=bigclassname;
  var i;
  document.myform.smallclassname.options[0] = new Option('请选择二级分类','');
  for (i=0;i < onecount; i++)
  {
  if (subcat[i][1] == bigclassname)
  { 
  document.myform.smallclassname.options[document.myform.smallclassname.length] = new Option(subcat[i][0], subcat[i][2]);
  }  
  }
   
  }  
</script>


<%sql2 = "select * from minclass order by minclassid asc"
set rs2 = conn.execute(sql2)
%>
<script language = "JavaScript">
var onecount2;
onecount2=0;
subcat2 = new Array();
  <%
  count2 = 0
  do while not rs2.eof 
  %>
subcat2[<%=count2%>] = new Array("<%= trim(rs2("minclassname"))%>","<%= trim(rs2("smallclassname"))%>","<%= trim(rs2("minclassname"))%>");
  <%
  count2 = count2 + 1
  rs2.movenext
  loop
  rs2.close
  set rs2=nothing
  %>
onecount2=<%=count2%>;

function changelocation2(smallclassname)
  {
  document.myform.minclassname.length = 0; 

  var smallclassname=smallclassname;
  var j;
  document.myform.minclassname.options[0] = new Option('请选择三级分类','');
  for (j=0;j < onecount2; j++)
  {
  if (subcat2[j][1] == smallclassname)
  { 
  document.myform.minclassname.options[document.myform.minclassname.length] = new Option(subcat2[j][0], subcat2[j][2]);
  }  
  }
   
  }  
</script>

 

<body onLoad="javascipt:setTimeout('loadForm()',1000);">


<form method="POST" name="myform" onSubmit="return CheckForm();" action="ArticleSave.asp?action=add" target="_self">
  <table width="620" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
   
  <tr align="center"> 
  <td class="tdbg"> <table width="100%" border="0" cellpadding="0" cellspacing="2">
  <tr> 
  <td width="151" height="22" align="right" bgcolor="#C0C0C0">所属类别:</td>
  <td width="467" bgcolor="#E3E3E3"> 
  <select name="bigclassname" onChange="changelocation(document.myform.bigclassname.options[document.myform.bigclassname.selectedIndex].value)" size="1">
  <option selected>请选择一级分类</option> 
  <% 
   
  sql1 = "select * from bigclass order by bigclassid asc"
  set rs1 = conn.Execute (sql1)
  do while not rs1.eof
  %>
  <option value="<%=trim(rs1("bigclassname"))%>"><%=trim(rs1("bigclassname"))%></option>
   
  <%
  rs1.movenext
  loop
  rs1.close
  set rs1 = nothing
  conn.Close
  set conn = nothing
  %>
  </select> 
   
  <select name="smallclassname" onChange="changelocation2(document.myform.smallclassname.options[document.myform.smallclassname.selectedIndex].value)">  
  <option selected value="">==所有二级分类==</option>
  </select>
   
  <select name="minclassname" size="1">  
  <option selected value="">==所有三级分类==</option>
  </select> </td>
  </tr>
   
   
   
  </table></td>
  </tr>
  </table>
  
   
</form>
  网页设计asp联动三级菜单表结构如下

BIGCLASS: bigclassid,bigclassname, 

smallclass smallclassid ,bigclassname,smallclassname

minclass minclassid,bigclassname,smallclassname,minclassname.

[/codes]

通过本文您对西安网站建设有了进一步了解,本公司温馨提醒:找西安做网站公司,请选择手续齐全、业务精、服务好的正规公司。

工商网上亮照

版权所有:西安点墨网络科技有限公司 信息备案编号: 陕ICP备11004160号-1

客户服务电话:029-89640155 18991365125

公司地址:西安市雁塔区朱雀大街紫郡长安F3

Sitemap 网站地图 手机版

办公电话:029-89640155

服务热线:18991365125

客服信箱:vip@dianmo.cc

846461336327

西安点墨网络科技有限公司

版权所有:西安点墨网络科技有限公司 信息备案编号: 陕ICP备11004160号-1