博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【转】asp二级联动的数据库版。
阅读量:4598 次
发布时间:2019-06-09

本文共 2412 字,大约阅读时间需要 8 分钟。

<!--#include file="include/conn.asp"-->
<script language = "javascript">
var j;
j=0;
goaler = new Array();
<%set rs=conn.execute("select * from SmallClass order by SmallClassID")
if rs.eof then%>
goaler[0] = new Array("无分类","","");
<%else
i=0
do while not rs.eof%>
goaler[<%=i%>] = new Array("<%=rs("SmallClassName")%>","<%=rs("BigClassID")%>","<%=rs("SmallClassID")%>");
<%rs.movenext
i=i+1
loop
end if
rs.close
%>
j=<%=i%>;

function changelocation(locationid)

{
document.goalerform.SmallClassID.length = 0;

var locationid=locationid;

var i;
for (i=0;i < j; i++)
{
if (goaler[i][1] == locationid)
{
document.goalerform.SmallClassID.options[document.goalerform.SmallClassID.length] = new Option(goaler[i][0], goaler[i][2]);
}
}

}

</script>

<form method="post" name="goalerform" action="">

<select name="BigClassID" onChange="changelocation(document.goalerform.BigClassID.options[document.goalerform.BigClassID.selectedIndex].value)" size="1">
<%set rs=conn.execute("select * from BigClass order by BigClassID")
if rs.eof then%>
<option selected value="">无一级分类</option>
<%else%>
<option selected value="">请选择一级分类</option>
<%do while not rs.eof%>
<option value="<%=rs("BigClassID")%>"><%=rs("BigClassName")%></option>
<%rs.movenext
loop
end if%>
</select>
<select name="SmallClassID">
<option selected value="">未指定一级分类</option>
</select>
<input type="submit" name="goaler" value="提交">
</form>

<%'测试取值
if request("goaler")<>"" then
response.write "BigClassID="&request("BigClassID")&"<BR>SmallClassID="&request("SmallClassID")
end if%>

--------==========================================================-----------------------

可能程序还有其它的同名的RECORDSET,为防止影响。可以改为

<%
SmallClassID=request.form("SmallClassID")
if SmallClassID<>"" then
set dansin=conn.execute("select titlename from News where Smallclassid="&SmallClassID
if not dansin.eof then
  do while not rs.eof
  response.write(dansin("titlename"))
  dansin.movenext
  loop
end if
dansin.close
else
response.write("SmallClassID值为空")
end if
  
<!-- #include virtual = "/include/conn.asp" -->
<%
SmallClassID=request.form("SmallClassID")
if SmallClassID<>"" then
set rs=conn.execute("select page_name from News where Smallclassid=" & SmallClassID)
if not rs.eof then
  do while not rs.eof
  response.write(rs("page_name"))
  rs.movenext
  loop
end if
else
response.write("SmallClassID值为空")
end if
rs.close
conn.close
%>

转载于:https://www.cnblogs.com/moretop/archive/2011/03/27/1997247.html

你可能感兴趣的文章
关于Cocos2d-x中背景音乐和音效的添加
查看>>
checkbox和文字对齐
查看>>
JConsole远程连接配置 服务器监控工具
查看>>
了解HTTP协议栈(实践篇)
查看>>
loj10035. 「一本通 2.1 练习 1」Power Strings
查看>>
%s的用法
查看>>
调用底层不能直接访问的类和方法
查看>>
清理缓存的方法 #DF
查看>>
JAVA array,map 转 json 字符串
查看>>
2017-12-27练习
查看>>
NET设计规范(二) 命名规范
查看>>
VMware 9.0.1安装Mac OS X Mountain Lion 10.8.2
查看>>
SSL延迟
查看>>
android新手关于左右滑动的问题,布局把<android.support.v4.view.ViewPager/><ImageView/> 放在上面就不行了。...
查看>>
深入理解DIP、IoC、DI以及IoC容器
查看>>
赋值文件
查看>>
Vue 数组 字典 template v-for 的使用
查看>>
蓝牙模块选择经验谈
查看>>
java中==和equals
查看>>
CCActionPageTurn3D
查看>>