一聚教程网:一个值得你收藏的教程网站

热门教程

asp多级联动菜单二

时间:2022-07-02 23:16:11 编辑:袖梨 来源:一聚教程网

asp多级联动菜单


<%
Dim xmlDoc, ParentCode, code
'Dim root As IXMLDOMElement
'Dim newElem As IXMLDOMElement
response.ContentType  = "text/xml" '输出格式为xml

ParentCode = Request("ParentCode")
If ParentCode = "" Then
 Response.Write ""
 Response.End
End If

set xmlDoc=CreateObject("Microsoft.XMLDOM") '新建xmldom对象
xmlDoc.loadXML("")

If ParentCode = "00" Then
 code = "__"
else
 code = ParentCode & "__"
End If

Set root = xmlDoc.documentElement

set rs=server.createobject("ADODB.recordset")
strSql="select y_id, y_code, [y_title] from m_style where y_code like '"&code&"'"
rs.Open strSQL,conn,1,1
If not rs.eof Then
do while not rs.eof  
   Set newElem = xmlDoc.createElement("TreeNode")
   root.appendChild newElem

   newElem.setAttribute "NodeId", "MaterialClass_" & rs("y_code")
   newElem.setAttribute "Title", rs("y_title")
   if len(rs("y_code"))<6 Then newElem.setAttribute "NodeXmlSrc", "Tree.asp?ParentCode=" & rs("y_code")
   newElem.setAttribute "Href", rs("y_code")
   newElem.setAttribute "MaterialClassCode", rs("y_code")
rs.movenext
loop
End If
rs.close
set rs = nothing

response.write(""&xmlDoc.xml)


%>
这里主要是先用asp  生成xml 文档再用 Microsoft.XMLDOM读取xml   给js进行分级,另外再提一点就可以直接在js代码中asp  代码让它生成js代码,这也是一种多级联动菜单 的处理办法

热门栏目