冰霜之子 2006-3-25 15:26
联动下拉框的问题
两个下拉菜单互动代码有问题,不能互动!
大家仔细帮我看一看到底哪里有问题?
<!--#include file="_SysLinks.asp" -->
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from _Web_Data_Small_Class order by class_id asc"
rs.open sql,conn,1,1
%>
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=SoftName%></title>
<link href="_Include/style.css" rel="stylesheet" type="text/css" />
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("Small_class"))%>","<%= trim(rs("Topic_id"))%>","<%= trim(rs("class_id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.class_id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.class_id.options[document.myform.class_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="16%"> </td>
<td width="84%" align="right"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<form name="myform" method="post" action="_Xwsjgl_Small_Class_AddResult.asp" onsubmit="return CheckData();">
<tr bgcolor="#FAFAFA">
<td align="right">大类别预览:</td>
<td>
<%
sql = "select * from _web_data_Big_class"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="classid" onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("Topic_id"))%>"><%=trim(rs("Big_class"))%></option>
<% dim selclass
selclass=rs("Topic_id")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("Topic_Id"))%>"><%=trim(rs("Big_class"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
</td>
</tr>
<tr bgcolor="#FAFAFA">
<td align="right">小类别预览:</td>
<td> <select name="Nclassid">
<%sql="select * from _Web_Data_Small_class where Topic_id="&selclass
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("class_ID")%>"><%=rs("Small_class")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("class_ID")%>"><%=rs("Small_class")%></option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
</select>
</td>
</tr>
<tr bgcolor="#FAFAFA">
<td width="31%" align="right">用户帐号:</td>
<td width="69%"><input name="Userid" type="text" class="form_1" id="Userid" value="<%=Session("userid")%>" size="60" readonly style="color:#666666;background:#f0f0f0" ></td>
</tr>
<tr bgcolor="#FAFAFA">
<td align="right">类型名称:</td>
<td><input name="DataClass" type="text" class="form_1" id="DataClass" size="60"></td>
</tr>
<tr bgcolor="#FAFAFA">
<td align="right"> </td>
<td><font color="#FF0000">注:类型名称最好为四个字!如"工作动态"</font></td>
</tr>
<tr bgcolor="#FAFAFA">
<td align="right"> </td>
<td> </td>
</tr>
xuyaoairen 2006-3-25 15:27
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
strScript="<script language = JavaScript>"
strScript=strScript+"var onecount;"
strScript=strScript+"onecount=0;"
strScript=strScript+"subcat = new Array();"
dim rs3,x,Bclass
set rs3=server.createobject("adodb.recordset")
sql="select * from Small_Class"
rs3.open sql,myConn
x=0
do while not rs3.eof
strScript=strScript+"subcat["&x&"] = new Array('"&rs3("Bclass")&"','"&rs3("Aclass")&"');"
rs3.movenext
x=x+1
loop
strScript=strScript+"onecount=150;"
strScript=strScript+"function changelocation(locationid)"
strScript=strScript+"{"
strScript=strScript+" document.myform.smallclass.length = 0;"
strScript=strScript+" var locationid=locationid;"
strScript=strScript+" var i;"
strScript=strScript+" for (i=0;i < onecount; i++)"
strScript=strScript+" {"
strScript=strScript+" if (subcat[i][1] == locationid)"
strScript=strScript+" { "
strScript=strScript+" document.myform.smallclass.options[document.myform.smallclass.length] = new Option(subcat[i][0], subcat[i][2]);"
strScript=strScript+" }}}"
strScript=strScript+"</script>"
Response.Write strScript
rs3.close
%>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="776" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#c6dfde" class="myTable">
<tr>
<td valign="top">
<div align="center"><br>
<font color="#006666"><strong>录 入 信 息</strong></font><br>
<br>
<%
id=Request.QueryString("id")
set rs=server.createobject("adodb.recordset")
sql="select * from product where id='"&id&"'"
rs.open sql,myConn,3,3
%>
</div>
<table width="100%" height="95%" border="1" align="center" cellpadding="5" cellspacing="0" class="L15">
<form name="myform" method="post" action="">
<tr>
<td colspan="2"> <div align="center">产 品 编 号:
<input name="bh" type="text" id="bh2" value="<%=rs("PID")%>" size="10">
一 级 分类:
<select name="bigclass" id="select" onChange="changelocation(document.myform.bigclass.options[document.myform.bigclass.selectedIndex].value)">
<option value="<%=rs("Big_Class")%>" selected><%=rs("Big_Class")%></option>
<%
set rs1=server.createobject("adodb.recordset")
sql="select * from Big_Class order by Big_ClassID asc"
rs1.open sql,myConn,3,3
if rs1.eof then
%>
<option value="">没有其他分类</option>
<%
else
rs1.movenext
do while not rs1.eof %>
<option value="<%=rs1("Aclass")%>"><%=rs1("Aclass")%></option>
<%
rs1.movenext
loop
rs1.close
end if
%>
</select>
二 级分 类:
<select name="smallclass" id="select2">
<option value="<%=rs("Small_Class")%>" selected><%=rs("Small_Class")%></option>
</select>
</div></td>
</tr>
</table>
</body>
</html>