| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 662 人关注过本帖
标题:[求助]ONCHANGE为什么只能实现二级联动
只看楼主 加入收藏
chenjiu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-3-22
收藏
 问题点数:0 回复次数:1 
[求助]ONCHANGE为什么只能实现二级联动

。。。。。
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= trim(rs("BigClassName"))%>");
<%
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]);
}
}
}


function changelocation1(location1id)
{
document.myform.SSmallClassName.length = 1;
var location1id=location1id;
var a;
for (a=0;a < onecount; a++)
{
if (subcat[a][1] == location1id)
{
document.myform.SSmallClassName.options[document.myform.SSmallClassName.length] = new Option(subcat[a][0], subcat[a][2]);
}
}
}

function AddItem(strFileName){
document.myform.IncludePic.checked=true;
document.myform.DefaultPicUrl.value=strFileName;
document.myform.DefaultPicList.options[document.myform.DefaultPicList.length]=new Option(strFileName,strFileName);
document.myform.DefaultPicList.selectedIndex+=1;
if(document.myform.UploadFiles.value==''){
document.myform.UploadFiles.value=strFileName;
}
else{
document.myform.UploadFiles.value=document.myform.UploadFiles.value+"|"+strFileName;
}
}

function CheckForm()
{
if (editor.EditMode.checked==true)
document.myform.Content.value=editor.HtmlEdit.document.body.innerText;
else
document.myform.Content.value=editor.HtmlEdit.document.body.innerHTML;

if (document.myform.Title.value=="")
{
alert("产品名称不能为空!");
document.myform.Title.focus();
return false;
}
if (document.myform.Product_Id.value=="")
{
alert("产品编号不能为空!");
document.myform.Key.focus();
return false;
}

if (document.myform.Content.value=="")
{
alert("产品内容不能为空!");
editor.HtmlEdit.focus();
return false;
}
return true;
}

</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<!-- #include file="Inc/Head.asp" -->

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="862" align="center" valign="top"> <b><br>
</b>
<form method="POST" name="myform" onSubmit="return CheckForm();" action="ProductSave.asp?action=add" target="_self">
<table width="620" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr align="center">
<td class="tdbg"> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="table_southidc">
<tr>
<td class="back_southidc" height="22" colspan="2" align="right" bgcolor="#A4B6D7"><div align="center"><b>添
加 产 品</b> </div></td>
</tr>
<tr>
<td width="150" height="22" align="right" bgcolor="#A4B6D7">所属类别:</td>
<td bgcolor="#E3E3E3"> <strong>
<%
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">
<option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
dim selclass
selclass=rs("BigClassName")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<%
sql="select * from SmallClass where BigClassName='" & selclass & "'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<select name="SmallClassName" onChange="changelocation1(document.myform.SmallClassName.options[document.myform.SmallClassName.selectedIndex].value)" size="1">
<option value="" selected>不指定小类</option>
<option selected value="<%=trim(rs("SmallClassName"))%>"><%=trim(rs("SmallClassName"))%></option>
<%
dim selclasss
selclasss=rs("SmallClassName")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("SmallClassName"))%>"><%=trim(rs("SmallClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="SSmallClassName">
<option value="" selected>不指定小类</option>
<%
sql="select * from SSmallClass where SmallClassName='" & selclasss & "'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option value="<%=trim(rs("SSmallClassName"))%>"><%=trim(rs("SSmallClassName"))%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=trim(rs("SSmallClassName"))%>"><%=trim(rs("SSmallClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
<%
ranNum=int(9*rnd)+10
iddata=month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
%>
</select>
</strong></td>
</tr>
</table>
<div align="center">
<p>
<input
name="Add" type="submit" id="Add" value=" 添 加 " onClick="document.myform.action='ProductSave.asp?action=add';document.myform.target='_self';">
&nbsp; </p>
</div>
</form></td>
</tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
</body>
</html>

搜索更多相关主题的帖子: ONCHANGE count Array trim 
2007-03-22 19:00
google
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:22
帖 子:3419
专家分:23
注 册:2005-11-1
收藏
得分:0 
三级也可以

不过个人感觉用AJAX就简单的多了

祝天下所有母亲幸福安康!~
2007-03-23 10:45
快速回复:[求助]ONCHANGE为什么只能实现二级联动
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037324 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved