ASP二级联动问题,选择了大类,但不显示对应的小类。请帮忙解决一下。课程设计马上就要交了。着急啊 10
这是大类的的字段,表名为:bigclass这是小类的字段,表名为:smallclass这是对应的ASP代码:<scriptlanguage="JavaScript">va...
这是大类的的字段,表名为:bigclass
这是小类的字段,表名为: smallclass
这是对应的ASP代码:
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassname"))%>","<%= trim(rs("BigClassid"))%>","<%= trim(rs("SmallClassname"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
<form method="POST" name="editForm" onSubmit="return CheckForm();" action="Bs_Article_Save.asp?action=Modify">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="100" height="22" align="right" bgcolor="#C0C0C0">所属栏目:</td>
<td width="600" bgcolor="#E3E3E3">
<%
if session("purview")=3 or session("purview")=4 then
response.write rsArticle("BigClassid") & "<input name='BigClassName' type='hidden' value='" & rsArticle("BigClassid") & "'>>>"
else
sql = "select * from BigClass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%>
<select name="BigClassName"
onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)" size="1">
<%
do while not rs.eof %>
<option <% if rs("BigClassid")=rsArticle("BigClassid") then response.Write("selected") end if%>
value="<%=rs("BigClassid")%>"><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if rs.close
%>
</select>
<% end if
if session("purview")=4 then
response.write rsArticle("SmallClassid") & "<input name='SmallClassName' type='hidden' value='" & rsArticle("SmallClassid") & "'>"
else
%>
<select name="SmallClassName">
<option value="" <%if rsArticle("SmallClassid")="" then response.write "selected"%>>不指定小类</option>
<%
sql="select * from SmallClass where BigClassid=" & rsArticle("BigClassid") & ""
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
do while not rs.eof
%>
<option <% if rs("SmallClassid")=rsArticle("SmallClassid") then response.Write("selected") end if%>
value="<%=rs("SmallClassname")%>"><%=rs("SmallClassName")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<%
end if
%> 展开
这是小类的字段,表名为: smallclass
这是对应的ASP代码:
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassname"))%>","<%= trim(rs("BigClassid"))%>","<%= trim(rs("SmallClassname"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
<form method="POST" name="editForm" onSubmit="return CheckForm();" action="Bs_Article_Save.asp?action=Modify">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="100" height="22" align="right" bgcolor="#C0C0C0">所属栏目:</td>
<td width="600" bgcolor="#E3E3E3">
<%
if session("purview")=3 or session("purview")=4 then
response.write rsArticle("BigClassid") & "<input name='BigClassName' type='hidden' value='" & rsArticle("BigClassid") & "'>>>"
else
sql = "select * from BigClass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%>
<select name="BigClassName"
onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)" size="1">
<%
do while not rs.eof %>
<option <% if rs("BigClassid")=rsArticle("BigClassid") then response.Write("selected") end if%>
value="<%=rs("BigClassid")%>"><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if rs.close
%>
</select>
<% end if
if session("purview")=4 then
response.write rsArticle("SmallClassid") & "<input name='SmallClassName' type='hidden' value='" & rsArticle("SmallClassid") & "'>"
else
%>
<select name="SmallClassName">
<option value="" <%if rsArticle("SmallClassid")="" then response.write "selected"%>>不指定小类</option>
<%
sql="select * from SmallClass where BigClassid=" & rsArticle("BigClassid") & ""
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
do while not rs.eof
%>
<option <% if rs("SmallClassid")=rsArticle("SmallClassid") then response.Write("selected") end if%>
value="<%=rs("SmallClassname")%>"><%=rs("SmallClassName")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<%
end if
%> 展开
2个回答
展开全部
<form method="POST" name="editForm" onSubmit="return CheckForm();" action="Bs_Article_Save.asp?action=Modify">
这一段代码改成
<form method="POST" name="myform" id="myform" onSubmit="return CheckForm();" action="Bs_Article_Save.asp?action=Modify">
就是表单名称的问题,以前我也经常这里出错,看下这样可以吗
这一段代码改成
<form method="POST" name="myform" id="myform" onSubmit="return CheckForm();" action="Bs_Article_Save.asp?action=Modify">
就是表单名称的问题,以前我也经常这里出错,看下这样可以吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询