大类表:
class
字段
id
classname小类表:
nclass
字段
id
nclassname
classid相关代码<!--#include file="conn.asp"-->
<%
dim rs
set rs=conn.execute("select * from nclass order by id asc")
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
var onecount;
onecount=0;
subcat = new Array();
<%
dim count
count=0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("nclassname"))%>","<%= trim(rs("classid"))%>","<%= trim(rs("id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;function changelocation(locationid)
{
document.form1.nclassid.length = 0; var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.nclassid.options[document.form1.nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
function report()
{
var options_string = "";
var the_select = window.document.form1.nclassid;
for (loop=0; loop < the_select.options.length; loop++)
{
if (the_select.options[loop].selected == true)
{ options_string += the_select.options[loop].text;
}
}
window.document.form1.nclassn2.value=options_string;
}</script>
<link href="../Images/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head><body>
<form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<tr>
<td width="100%">
<div align="center"></div></td>
</tr>
<tr>
<td width="100%">
<table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
<tr>
<td height="25" bgcolor="#23458B"><span class="style1">添加二级类别:</span></td>
</tr>
<tr>
<td height="25"><%
sql="select * from class order by id asc"
set rs=conn.execute(sql)
if not rs.eof then
%>
选择类别:
<select name="classid" id="select" onChange="report();">
<option value="">--请选择类别--</option>
<%do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("classname")%></option>
<%rs.movenext
loop
%>
</select>
填写二级类别名称:
<input name="nclassname" type="text" id="nclassname2" size="15">
<input type="submit" name="Submit" value="添加">
<%else%>
没有任何类别,请添加类别!
<%end if%></td>
</tr>
</table>
<br>
<table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
<tr>
<td height="25" bgcolor="#23458B"><span class="style1">对类别进行添加和删除:</span></td>
</tr>
<tr>
<td height="50">
<%
dim selclass
sql="select * from class"
set rs=conn.execute(sql)
if not rs.eof then
%>
选择类别:
<select name="classid2" id="classid2" onChange="changelocation(document.form1.classid2.options[document.form1.classid2.selectedIndex].value)">
<option value="">--请选择类别--</option>
<%
if not rs.eof then
selclass=rs("id")
%>
<option value="<%=rs("id")%>" selected><%=rs("classname")%></option>
<%
rs.movenext
end if%>
<%do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("classname")%></option>
<%
rs.movenext
loop
%>
</select>
<select name="nclassid" onChange="report();">
<%
sql="select * from nclass where classid='"&selclass&"' order by id asc"
set rs=conn.execute(sql)
if not(rs.eof and rs.bof) then do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("nclassname")%></option>
<% rs.movenext
loop
end if
%>
</select>
<br>
类别名称:
<input name="nclassn2" type="text" id="nclassn2">
<input type="submit" name="Submit" value="修改">
<input type="button" name="Submit" value="删除" onClick="nclass_del();">
<%else%>
没有任何类别,请添加类别!
<%end if%>
</td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
class
字段
id
classname小类表:
nclass
字段
id
nclassname
classid相关代码<!--#include file="conn.asp"-->
<%
dim rs
set rs=conn.execute("select * from nclass order by id asc")
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
var onecount;
onecount=0;
subcat = new Array();
<%
dim count
count=0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("nclassname"))%>","<%= trim(rs("classid"))%>","<%= trim(rs("id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;function changelocation(locationid)
{
document.form1.nclassid.length = 0; var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.nclassid.options[document.form1.nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
function report()
{
var options_string = "";
var the_select = window.document.form1.nclassid;
for (loop=0; loop < the_select.options.length; loop++)
{
if (the_select.options[loop].selected == true)
{ options_string += the_select.options[loop].text;
}
}
window.document.form1.nclassn2.value=options_string;
}</script>
<link href="../Images/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head><body>
<form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<tr>
<td width="100%">
<div align="center"></div></td>
</tr>
<tr>
<td width="100%">
<table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
<tr>
<td height="25" bgcolor="#23458B"><span class="style1">添加二级类别:</span></td>
</tr>
<tr>
<td height="25"><%
sql="select * from class order by id asc"
set rs=conn.execute(sql)
if not rs.eof then
%>
选择类别:
<select name="classid" id="select" onChange="report();">
<option value="">--请选择类别--</option>
<%do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("classname")%></option>
<%rs.movenext
loop
%>
</select>
填写二级类别名称:
<input name="nclassname" type="text" id="nclassname2" size="15">
<input type="submit" name="Submit" value="添加">
<%else%>
没有任何类别,请添加类别!
<%end if%></td>
</tr>
</table>
<br>
<table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
<tr>
<td height="25" bgcolor="#23458B"><span class="style1">对类别进行添加和删除:</span></td>
</tr>
<tr>
<td height="50">
<%
dim selclass
sql="select * from class"
set rs=conn.execute(sql)
if not rs.eof then
%>
选择类别:
<select name="classid2" id="classid2" onChange="changelocation(document.form1.classid2.options[document.form1.classid2.selectedIndex].value)">
<option value="">--请选择类别--</option>
<%
if not rs.eof then
selclass=rs("id")
%>
<option value="<%=rs("id")%>" selected><%=rs("classname")%></option>
<%
rs.movenext
end if%>
<%do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("classname")%></option>
<%
rs.movenext
loop
%>
</select>
<select name="nclassid" onChange="report();">
<%
sql="select * from nclass where classid='"&selclass&"' order by id asc"
set rs=conn.execute(sql)
if not(rs.eof and rs.bof) then do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("nclassname")%></option>
<% rs.movenext
loop
end if
%>
</select>
<br>
类别名称:
<input name="nclassn2" type="text" id="nclassn2">
<input type="submit" name="Submit" value="修改">
<input type="button" name="Submit" value="删除" onClick="nclass_del();">
<%else%>
没有任何类别,请添加类别!
<%end if%>
</td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
解决方案 »
- 把键盘焦点给予一个窗口是什么意思??
- 屏蔽非IE浏览器的代码,禁止傲游,TT,火狐,36se,谷歌等非IE浏览器!
- 大家谈谈外包公司怎样?
- 求一正则表达式。。
- 用JS如何来做个重定向,望大哥们给个思路,有代码最好!
- 求一个对话框插件。最好是基于JQUERY的
- JS在网页上作图的问题,急啊,请教高人
- javascript的错误就是让人难以捉摸 attachEvent的怪现象
- 请问:怎样用javascript判断日期的有效性,和比较两个时间的大小
- window.onload跟<body onload="">有什么区别?
- 关于:<script language="javascript" src="../SessionJs.jsp"></script>的问题
- 关闭窗口问题
http://sz.luohuedu.net/xml/Exam/MultiSelect.zip