<!--#include file="../siteconfig/conn.asp"-->
<HTML>
<HEAD>
<TITLE>分类管理</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<LINK REL="stylesheet" HREF="css.css" TYPE="text/css">
</HEAD>
<script language="JavaScript" type="text/javascript" src="js.js"></script>
<BODY>

<%
set rs=server.createobject("adodb.recordset")
set rss=server.createobject("adodb.recordset")

dim RsClass(5)
function listunder(e)
	set RsClass(e)=server.createobject("adodb.recordset")
	RsClass(e).open "select Class_Id,Class_Name from Class where Class_TopClassId="&RsClass(e-1)("Class_Id"),conn,1,3
	while not RsClass(e).eof
		dim topclassname
		topclassname=""
		for x=0 to e-1
			topclassname=topclassname&RsClass(x)("Class_Name")&"＞"
		next
		SelectValue=SelectValue&","""&RsClass(e)("Class_Id")&""""
		SelectMenu=SelectMenu&","""&topclassname&RsClass(e)("Class_Name")&""""
   rs.open"select UrlClass_Id,UrlClass_Name from UrlClass where UrlClass_ClassId="&RsClass(e)("Class_Id"),conn,1,3
		SelectClassValue=SelectClassValue&"["
		SelectClassMenu=SelectClassMenu&"["
		dim UCi
		UCi=0
   while not rs.eof
   if UCi>0 then
      SelectClassValue=SelectClassValue&","""&rs("UrlClass_Id")&""""
	  SelectClassMenu=SelectClassMenu&","""&rs("UrlClass_Name")&""""
	else
      SelectClassValue=SelectClassValue&""""&rs("UrlClass_Id")&""""
	  SelectClassMenu=SelectClassMenu&""""&rs("UrlClass_Name")&""""
	end if
	UCi=3
	rs.movenext
	wend
	rs.close
		SelectClassValue=SelectClassValue&"]"
		SelectClassMenu=SelectClassMenu&"]"
		if i<Ubound(RsClass) then
			call listunder(e+1)
		end if
		RsClass(e).movenext
	wend
end function


dim SelectValue,SelectMenu,SelectClassValue,SelectClassMenu,Ci,Cj,UCi
set RsClass(0)=server.createobject("adodb.recordset")
RsClass(0).open "select Class_Id,Class_Name from Class where Class_TopClassId=0",conn,1,3
while not RsClass(0).eof
	if Ci>0 then
		SelectValue=SelectValue&","""&RsClass(0)("Class_Id")&""""
		SelectMenu=SelectMenu&","""&RsClass(0)("Class_Name")&""""
		SelectClassValue=SelectClassValue&",["
		SelectClassMenu=SelectClassMenu&",["
	else
		SelectValue=SelectValue&"""0"","""&RsClass(0)("Class_Id")&""""
		SelectMenu=SelectMenu&"""-选择主分类-"","""&RsClass(0)("Class_Name")&""""
		SelectClassValue=SelectClassValue&"[""0""],["
		SelectClassMenu=SelectClassMenu&"[""子分类""],["
	end if
	Cj=0
   rs.open"select UrlClass_Id,UrlClass_Name from UrlClass where UrlClass_ClassId="&RsClass(0)("Class_Id"),conn,1,3
   while not rs.eof
   if Cj>0 then
      SelectClassValue=SelectClassValue&","""&rs("UrlClass_Id")&""""
	  SelectClassMenu=SelectClassMenu&","""&rs("UrlClass_Name")&""""
	else
      SelectClassValue=SelectClassValue&""""&rs("UrlClass_Id")&""""
	  SelectClassMenu=SelectClassMenu&""""&rs("UrlClass_Name")&""""
	end if
		Cj=3
	rs.movenext
	wend
	rs.close
	Ci=3
		SelectClassValue=SelectClassValue&"]"
		SelectClassMenu=SelectClassMenu&"]"
	call listunder(1)
	RsClass(0).movenext
wend
SelectClassMenu="["&SelectClassMenu&"]"
SelectClassValue="["&SelectClassValue&"]"
SelectMenu="["&SelectMenu&"]"
SelectValue="["&SelectValue&"]"
response.write ""&SelectClassMenu&"<br />"
response.write ""&SelectClassValue&"<br />"
response.write ""&SelectValue&"<br />"
response.write ""&SelectMenu&""
%>

<div id="tar"></div>
<SCRIPT LANGUAGE="JavaScript" DEFER>
var fMenu = <%=SelectMenu%>
var fValue = <%=SelectValue%>
var sMenu = <%=SelectClassMenu%>
var sValue = <%=SelectClassValue%>

var oWhere = document.all.tar;
var ofMenu = document.createElement("<SELECT name='main'>");
var osMenu = document.createElement("<SELECT name='sub'>");
with(oWhere)appendChild(ofMenu),appendChild(osMenu);

createMainOptions();
createSubOptions(0);

ofMenu.onchange = function() {createSubOptions(this.selectedIndex);};

function createMainOptions() {
     for(var i=0;i<fMenu.length;i++)ofMenu.options[i] = new Option(fMenu[i],fValue[i]);
}
function createSubOptions(j) {
     with(osMenu) {
         length=0;
         for(var i=0;i<sMenu[j].length;i++)osMenu.options[i] = new Option(sMenu[j][i],sValue[j][i]);
     }
}
</SCRIPT> 
</BODY>
</HTML>

