困扰了我好久的问题了,请高手解答!!

沙漠中的甲壳虫 2004-01-30 01:38:28
两个下拉菜单,t选项为两个关联表的动态数据,两个表的数据随时会更新,第一个下拉菜单选定项目后,第二个下拉菜单的项目要成为第一个下拉菜单的子项目.
比如说:
表一为:表:单位
例为:单位ID,单位名称,地址,法人代表
表二为:表:联系人
列为:联系人ID,姓名,单位ID,电话,
下拉菜单1:单位
下拉菜单2:单位ID相同的所有联系人姓名
...全文
80 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
cslf 2004-02-01
  • 打赏
  • 举报
回复
给点提示:把 billy36() 的代码稍微修改即可,把构造的vbsrcipt response.write
set rs=createobject("adodb.recordset")
rs.cursorloction=3
rs.open sql,cn,1,3

redim wherearr(1 to rs.recordcount)
...
  • 打赏
  • 举报
回复
up..........................
  • 打赏
  • 举报
回复
谢谢大家,可我要的是vbscript做的啊,我没学过javascript
snower01 2004-01-30
  • 打赏
  • 举报
回复
数据库关联

<script language=javascript>
function ch(selectedids,n)
{
var selectedvalue=selectedids
var i
var t=0
document.form1.s2.length=0
for(i=0;i<n;i++)
{
if(subcat[i][0]==selectedvalue)
{
document.form1.s2.options[t]=new

Option(subcat[i][1],subcat[i][2])
t=t+1
}
}
}
function check()
{
if (document.form1.s1.options.selectedIndex==0)
{
alert("请先选择类别")
document.form1.s1.focus()
return false
}
return true
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="780" border="0" cellspacing="0" cellpadding="0"

height="38%" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="19%" valign="top" bgcolor="#FFCC00"> <!--#include

file="menu3.asp" -->
</td>
<td width="81%" height="478" valign="top">
<form name="form1" method="post" action="do_mod.asp" onsubmit="return

datacheck()">
<table width="100%" border="0">
<tr bgcolor="#E6E0FE">
<td width="12%" align="center">物品类别
</td>
<td colspan="6">
<script language="javascript">
var subcat=new Array()
<%
dim n
n=0
set rs=server.CreateObject("adodb.recordset")
rs.ActiveConnection=conn
rs.Source="select a.T_catid,a.T_name as xx ,a.T_id from cos_T_manage a

join cos_T_catagery b on a.T_catid=b.T_id"
rs.CursorType=1
rs.LockType=1
rs.Open
do while not rs.EOF%>
subcat[<%=n%>]=new

Array("<%=rs("T_catid")%>","<%=rs("xx")%>","<%=rs("T_id")%>")
<%n=n+1
rs.movenext
loop
%></script>
<select name="s1"

onchange="ch(this.options[this.selectedIndex].value,<%=n%>)">
<option value="0">--请选择--</option>
<%set rsd=server.CreateObject("adodb.recordset")
rsd.ActiveConnection=conn
rsd.Source="select T_id,T_name from cos_t_catagery"
rsd.Open
do while not rsd.EOF
%>
<option value="<%=rsd("T_id")%>">
<%=rsd("T_name")%>
</option>
<%rsd.MoveNext
loop
%>
</select>
</td>
</tr>
<tr bgcolor="#E6E0FE">
<td width="12%" align="center">物品名称</td>
<td colspan="6">
<select name="s2" onclick="check()"></select>
</td>
</tr>
TrueAndFalse 2004-01-30
  • 打赏
  • 举报
回复
根据你的结构,改一下

<%
dim count
set rs=server.createobject("adodb.recordset")
sql = " select ChanelId,ChanelName,ChanelParentId from Chanel where ChanelParentId<>0 and ChanelVis=true"rs.open sql,connstr,1,1%>
<script language="JavaScript">
var tempcount;
tempcount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
temparr[<%=count%>] = new Array("<%= trim(rs("ChanelName"))%>","<%= trim(rs("ChanelParentId"))%>","<%= trim(rs("ChanelId"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
tempcount=<%=count%>;

function changeit(itid)
{
document.form1.smallclassid.length = 0;
var itid=itid;
var i;
for (i=0;i < tempcount; i++)
{
if (temparr[i][1] == itid)
{
document.form1.smallclassid.options[document.form1.smallclassid.length] = new Option(temparr[i][0], temparr[i][0]);
}
}

}
</script>
<%
sql = "select ChanelId,ChanelName from Chanel where ChanelParentId=0 and ChanelVis=true"
rs.open sql,connstr,1,1
if rs.eof and rs.bof then
response.write "请先添加主栏目"
response.end
else
%>
<select name="bigclassid" id="bigclassid" onChange="changeit(document.form1.bigclassid.options[document.form1.bigclassid.selectedIndex].value)">
<option selected value="">选择主栏目</option>
<% do while not rs.eof %>
<option value="<%=trim(rs("ChanelId"))%>"><%=trim(rs("ChanelName"))%></option>

<%
rs.movenext
loop
end if
rs.close
set rs=nothing
%>
</select>
<select id="smallclassid" name="smallclassid" >
<option selected value="">选择子栏目</option>
</select>
xzq686 2004-01-30
  • 打赏
  • 举报
回复
用asp+javascript实现动态数据联动:
http://www.webasp.net/tech/article_show.asp?id=13674&fieldby=title&keyword=联动
nchen123 2004-01-30
  • 打赏
  • 举报
回复
asp + vbscript 类似, 原先 javascript 里用数组, 改成用 vbscript 的 dictionary 对象
  • 打赏
  • 举报
回复
asp+vbscript可以实现吗?
hongmaohouzi 2004-01-30
  • 打赏
  • 举报
回复
用一个查询语句,由选择的条件来控制下级菜单!
PPLUNCLE 2004-01-30
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2661/2661683.xml?temp=.6863367
全息宇宙 2004-01-30
  • 打赏
  • 举报
回复
只需要将其中的表名称和字段名替换一下就OK!
全息宇宙 2004-01-30
  • 打赏
  • 举报
回复
以前写的一个大类小类联动改变的东西,参考一下:
<%
'// +-----------------------------------------------------------------------------------+
'// | 大类小类改变模块 |
'// | --------------------------------------------------------------------------------- |
'// | 程序流程: |
'// | --------------------------------------------------------------------------------- |
'// | 系统:win2000; 编辑器:EditPlus; 缩进工具:Tab; 缩进长度:8; 字体:宋体(10pt); |
'// | --------------------------------------------------------------------------------- |
'// | 创建者: WYC; 创建时间: 2003-11-29; |
'// | 编写者: WYC; 编写时间: 2003-11-29; |
'// +-----------------------------------------------------------------------------------+
%>
<!--#include file="DBCONN.asp"-->
<HTML>
<BODY leftmargin="0" topmargin="0" bgcolor="#F0F4F0">
<script>
function load() //响应网页载入事件 wyc(2003-11-10)
{
parent.document.all.sortid_1.value = document.all.sortid.value;
}
function sortchange() //大类改变函数 wyc(2003-11-10)
{
window.location.href = "class_all.asp?sortid=" + document.all.sortid.value;
}
function typechange() //小类改变函数 wyc(2003-11-10)
{
parent.document.all.sortid_1.value = document.all.sortid.value;
parent.document.all.typeid.value = document.all.typeid.value;
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100">
<SELECT name="sortid" onchange="sortchange()">
<option value="" <%if request("sortid")="" then response.write "selected"%>>请选择您的行业大类</option>
<%
id_ = request("sortid")
if id_="" then
id_ = 0
end if
set rssort = server.createobject("adodb.recordset")
sortsql = "select * from class_1"
rssort.open sortsql,conn,1,1
do while not rssort.eof
if cint(id_) = rssort("sortid") then
sel = "selected"
else
sel = ""
end if
response.write "<option value='"&cstr(rssort("sortid"))&"' "&sel&">"&rssort("sort")&"</option>"
rssort.movenext
loop
rssort.close
set rssort = nothing
%>
</SELECT>
</td>
<td>
 <SELECT name="typeid" onchange="typechange()">
<OPTION value="" selected>请选择您的行业小类</option>
<%
if request("sortid")<>"" then
set rstype = server.createobject("adodb.recordset")
typesql = "select * from class_2 where sortid="&request("sortid")
rstype.open typesql,conn,1,1
do while not rstype.eof
response.write "<option value='"&cstr(rstype("typeid"))&"'>"&rstype("typename")&"</option>"
rstype.movenext
loop
rstype.close
set rstype = nothing
end if
%>
</SELECT> <FONT color=#ff6600 style="font-size:12px;">※</FONT> </td>
</tr>
</table>
</BODY>
</HTML>
jzywh 2004-01-30
  • 打赏
  • 举报
回复
二维数组,或Directory
billy36 2004-01-30
  • 打赏
  • 举报
回复
当然这个可以用ASP动态生成,一个循环就行

where[1] = new comefrom("北京","|东城|西城|崇文|宣武|朝阳|丰台|石景山|海淀|门头沟|房山|通州|顺义|昌平|大兴|平谷|怀柔|密云|延庆");
  • 打赏
  • 举报
回复
两个下拉菜单,t选项为两个关联表的动态数据,两个表的数据随时会更新,第一个下拉菜单选定项目后,第二个下拉菜单的项目要成为第一个下拉菜单的子项目.
比如说:
表一为:表:单位
例为:单位ID,单位名称,地址,法人代表
表二为:表:联系人
列为:联系人ID,姓名,单位ID,电话,
下拉菜单1:单位
下拉菜单2:所选单位的所有联系人姓名

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧