一個強健實用的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>