三级联动菜单问题,高手帮帮忙

zhanglixin1234567 2009-08-13 05:32:38


<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#E8E8E8" class="t1">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" height="25" bgcolor="#E8E8E8"> </td>
<td width="10" height="25" bgcolor="#F0F0F0"> </td>
<td bgcolor="#F7F7F7" class="font14pxB">添加教材信息</td>
</tr>
<tr>
<td height="5" colspan="3"> </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30" height="20"> </td>
<td height="20" class="linkText"><span class="linkText"><strong>S:</strong></span>选择标识 <strong>注</strong>:前台页面将显示最新添加的一条信息</td>
</tr>
</table></td>
</tr>
</table>
<br>

<script language="javascript">


function check()
{
var f1=document.form1;
if(f1.atype.value=="")
{
window.alert("系统提示:教材类别不能为空!");
return false;
}
if(f1.title.value=="")
{
window.alert("系统提示:教材标题不能为空!");
f1.title.focus();
return false;
}
if(f1.content.value=="")
{
window.alert("系统提示:信息详细内容不能为空!");
return false;
}

}

</script>

<%
dim rs,sql

dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from jcdg_type_b order by bid asc"
rs.open sql,conn,1,1
%>

<script language="javascript">


var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("btype"))%>","<%= trim(rs("aid"))%>","<%= trim(rs("btype"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;

function changelocation(locationid)
{
document.form1.bbid.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.bbid.options[document.form1.bbid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>









<table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC" class="t1">
<form name="form1" method="POST" action="save_news.asp" onSubmit="return check();" enctype="multipart/form-data">
<tr>

<td width="20%" height="30" align="right" bgcolor="#F4F4F4">
<div align="right"> 教材类别:</div></td>

<td width="80%" height="30" colspan="2">
 



<%
sql = "select * from jcdg_type_a"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%>
<select name="aaid" onChange="changelocation(document.form1.aaid.options[document.form1.aaid.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("aid"))%>"><%=trim(rs("atype"))%></option>
<%
dim aidlj
aidlj=rs("aid")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("aid"))%>"><%=trim(rs("atype"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="bbid" >
<option value="" selected>不指定小类</option>

<%
sql="select * from jcdg_type_b where aid='" & aidlj & "'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option value="<%=rs("bid")%>"><%=rs("btype")%></option>

<%
dim bidlj
bidlj=rs("bid")
rs.movenext
do while not rs.eof%>
<option value="<%=rs("bid")%>"><%=rs("btype")%></option>
<%
rs.movenext
loop
end if
rs.close
%>

</select>
<select name="ccid">
<option value="" selected>不指定小类</option>
<%
sql="select * from jcdg_type_c where aid='"&aidlj&"' and bid='"&bidlj&"' "
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option value="<%=rs("cid")%>"><%=rs("ctype")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("cid")%>"><%=rs("ctype")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>




<strong><span class="font4"><font color="#FF0000"> * </font></span></strong>
<div align="right"></div></td>
</tr>
<tr >
<td height="28" align="right" bgcolor="#F4F4F4"><div align="right"> 标题:</div></td>
<td height="28" align="left" colspan="2"><input type="text" name="title" size="60"> <strong><font color="#FF0000">* </font></strong>
</td>
</tr>
<tr >
<td height="28" align="right" bgcolor="#F4F4F4"><div align="right"> 详细内容:</div></td>
<td height="28" align="left" colspan="2">[<a href="#" onClick="to_edit('form1','title','content');return false;"><font color="#FF0000">编辑内容</font></a>] <strong><span class="font4"><font color="#FF0000"> * </font></span></strong>
</td>
</tr>
<tr style="display:none">
<td height="28" align="right" bgcolor="#F4F4F4"> </td>
<td height="28" align="left" colspan="2"><input type="file" name="mpic"><textarea rows="1" cols="50" name="content" ></textarea></td>
</tr>
<tr>
<td height="30" colspan="3">
<input name="save1" type="submit" class="b-input" value="保 存" style="width:100px">
<input name="reset1" type="reset" class="b-input" value="清 除" style="width:100px"> </td>
</tr>
</form>
</table>



<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}

function to_edit(f,t,c){
MM_openBrWindow('../editer_mkj/editer.asp?f='+f+'&t='+t+'&c='+c,'to_edit','scrollbars=yes,resizable=yes,status=yes,width=565,height=480');
}
//-->
</script>



注:1、2级能好用,3级老是错误
...全文
40 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ITcql 2009-08-13
1楼的很不错啊,学习了。
回复
sy_binbin 2009-08-13
你直接把我的代码复制过去!数据表,字段改成你自己的
回复
谢谢2楼,哪个哥哥,在原有代码上帮我改下,谢谢啦,老板催的急。
回复
sy_binbin 2009-08-13
<script>
<!--
<%
'二级数据保存到数组
Dim count2,cityRS,citySQL
set cityRS=server.createobject("adodb.recordset")
citySQL="select * from sys_city"
cityRS.open citySQL,conn,1,1
%>
var subval2 = new Array();
//数组结构:一级根值,二级根值,二级显示值
<%
count2 = 0
do while not cityRS.eof
%>
subval2[<%=count2%>] = new Array('<%=cityRS("provinceid")%>','<%=cityRS("id")%>','<%=cityRS("cityname")%>')
<%
count2 = count2 + 1
cityRS.movenext
loop
cityRS.close
%>
<%
'三级数据保存到数组
Dim count3,townRS,townSQL
set townRS=server.createobject("adodb.recordset")
townSQL="select * from sys_town"
townRS.open townSQL,conn,1,1
%>
var subval3 = new Array();
//数组结构:二级根值,三级根值,三级显示值
<%
count3 = 0
do while not townRS.eof
%>
subval3[<%=count3%>] = new Array('<%=townRS("cityid")%>','<%=townRS("ID")%>','<%=townRS("townname")%>')
<%
count3 = count3 + 1
townRS.movenext
loop
townRS.close
%>
function changeselect1(locationid)
{
document.form1.cityID.length = 0;
document.form1.cityID.options[0] = new Option('请选择城市','');
document.form1.townID.length = 0;
document.form1.townID.options[0] = new Option('请选择城区','');
for (i=0; i<subval2.length; i++)
{
if (subval2[i][0] == locationid)
{document.form1.cityID.options[document.form1.cityID.length] = new Option(subval2[i][2],subval2[i][1]);}
}
}

function changeselect2(locationid)
{
document.form1.townID.length = 0;
document.form1.townID.options[0] = new Option('请选择城区','');
for (i=0; i<subval3.length; i++)
{
if (subval3[i][0] == locationid)
{document.form1.townID.options[document.form1.townID.length] = new Option(subval3[i][2],subval3[i][1]);}
}
}
//-->
</script>
<form id="form1" name="form1" method="post" action="">
<%
Dim count1,provinceRS,provinceSQL
set provinceRS=server.createobject("adodb.recordset")
provinceSQL="select * from sys_province order by orderfield"
provinceRS.open provinceSQL,conn,1,1
%>

<select name="provinceID" id="provinceID" onChange="changeselect1(this.value)">
<option value="">请选择省份</option>
<%
do while not provinceRS.eof
response.Write "<option value="&provinceRS("ID")&">"&provinceRS("provincename")&"</option>"
provinceRS.movenext
loop
provinceRS.close
set provinceRS = nothing
%>
</select>
<select name="cityID" id="cityID" onChange="changeselect2(this.value)">
<option value="">请选择城市</option>
</select>
<select name="townID" id="townID">
<option value="">请选择城区</option>
</select>
</form>
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告