一个强健 实用的ajax二级联动菜单(有演示和附源程序打包下载)
前些天在搞后台的时候要用到二级联动的菜单,到网上去找了半天也没找到满意的,不是这错就是那错,在选择的时候有时候不能返回.真是郁闷.
后来就看到有人用ajax写了无限级分类(牛,呵呵,本人看不懂.).就想到我那个后台不也可以用ajax试试,虽然比用javascript的慢点,但我这个实用.强健..不会出错,也不会选择某个大类后再返回无选择状态小类为空的状态.呵呵.
文件目录:如图
主要代码如下:
index.asp
复制代码代码如下:
<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"c/>
<title>Ajax的二级联动by啊峰</title>
<scriptlanguage="javascript"src="js.js"></script>
</head>
<body>
<h2><ahref="http://yeahdown.com/">Ajax的二级联动by啊峰</a></h2>
<!--#includefile="iconn.asp"-->
<%
Setafeng=Conn.Execute("selectbigclassid,bigclassnamefrombigclass")
%>
<formid="form1"name="form1"method="post"action="">
<divid="bigclass"style="float:left">
<selectname="select">
<optionvalue="0">选择一级分类</option>
<%IfNotafeng.Eofthen
DoWhileNotafeng.Eof
bigclassid=afeng("bigclassid")
bigclassname=afeng("bigclassname")%>
<optionvalue="<%=bigclassid%>"><%=bigclassname%></option>
<%afeng.Movenext
Loop
EndIf
afeng.Close
Setafeng=Nothing
Conn.Close
SetConn=Nothing%>
</select>
</div>
<divid="subclass"style="float:left"><selectname="select2">
<optionvalue="0">选择二级分类</option>