您的位置:首页 > 编程语言 > ASP

ASP新闻栏目切换+JS

2007-03-28 11:44 423 查看
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from kml_sclass"
rs.open sql,conn,1,1
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("sclassname"))%>","<%= trim(rs("bclassid"))%>","<%= trim(rs("sclassid"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;

function changelocation(locationid)
{
document.myform.sclassid.length = 0;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.sclassid.options[document.myform.sclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
</head>
<body>
<br>
<form name="myform" method="post" action="?action=addsave">
<table width="80%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
<tr bgcolor="#F6F6F6">
<td height="25" colspan="2"><div align="center"><strong>修 改 新 闻</strong></div></td>
</tr><tr bgcolor="#F6F6F6"><td align="center" height="25">新闻样式:</td><td><input name="jibie" type="radio" value="0" checked>
中文版</td></tr>
<tr>
<td width="15%" height="25" align="right" bgcolor="#F6F6F6">文章类型:</td>
<td width="85%" bgcolor="#FFFFFF">
<%
sql = "select * from kml_bclass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="bclassid" onChange="changelocation(document.myform.bclassid.options[document.myform.bclassid.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("bclassid"))%>"><%=trim(rs("bclassname"))%></option>
<%dim selclass
selclass=rs("bclassid")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("bclassid"))%>"><%=trim(rs("bclassname"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="sclassid">
<%
sql="select * from kml_sclass where bclassid="&selclass
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("sclassID")%>"><%=rs("sclassname")%></option>
<%
rs.movenext
do while not rs.eof
%>
<option <%if RsEdit("sclassid")=rs("sclassID") then %> selected <% end if %>value="<%=rs("sclassID")%>"><%=rs("sclassname")%></option>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: