急求!怎么将ASP二级联动的值存储到另一个表里?
我的是ACCSS数据表部门表是:provincenc_id(自动编号)nc_name(部门名称)(文本)人员表名:useid(自动编号)name(用户名)(文本)nc_u...
我的是ACCSS数据表
部门表是:province
nc_id(自动编号) nc_name(部门名称)(文本)
人员表名:use
id(自动编号) name(用户名)(文本) nc_upid(所属部门)
发布表名:news 怎么将二级联动菜单的发布部门和发布人的值存储到news表里的name ,selec字段里。代码如下:
<!--#include file="../config/db.ASP" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language = "JavaScript">
<%
dim count
set rs=server.createobject("ADODB.Recordset")
sql = "select * from use order by id asc"
rs.open sql,conn,1,1
%>
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= Left(rs("name"),10)%>","<%= trim(rs("nc_upid"))%>","<%= trim(rs("id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changeClass(locationid)
{
document.form1.formUserName.length = 0;
var locationid=locationid;
var i;
document.form1.formUserName.options[0] = new Option('-----请选择用户-----','');
for (i=0;i < onecount; i++)
{if (subcat[i][1] == locationid)
{
//alert(subcat[i][1]);
document.form1.formUserName.options[document.form1.formUserName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="../config/dtfb_check.asp" onSubmit="return check()">
<table width="776" border="1" align="center" cellpadding="0" cellspacing="0" background="../imager/bj.gif">
<tr>
<td height="30" colspan="6"><div align="center"><span class="style1 style4"><strong>发布工作动态</strong></span></div></td>
</tr>
<tr>
<td width="100" height="30"><div align="center"><span class="style3">工作动态标题:</span></div></td>
<td width="181"><input name="title" type="text" id="title"></td>
<td width="66"><div align="center"><span class="style3">发布部门:</span></div></td>
<td width="160">
<select name="formUnitId" onChange="changeClass(document.form1.formUnitId.options[document.form1.formUnitId.selectedIndex].value)">
<option value="" selected>-----请选择部门-----</option>
<% sql="select * from province order by nc_sort asc"
rs.open sql,conn,1,1
do while not rs.eof
%>
<option value="<%=rs("nc_name")%>"><%=rs("nc_name")%></option>
<% rs.movenext
loop
rs.close
%>
</select></td>
<td width="64"><div align="center"><span class="style3">发布人:</span></div></td>
<td width="191">
<select name="formUserName">
<option value="" selected>-----请选择用户-----</option>
</select></td>
</tr>
<tr>
<td><div align="center"><span class="style2 style3">工作动态内容:</span></div></td>
<td colspan="5"><span class="style3">
<textarea name="textarea" cols="89" rows="50"></textarea>
</span></td>
</tr>
<tr>
<td colspan="6"><div align="center">
<input type="submit" name="Submit" value="提交">
</div></td>
</tr>
</table>
</form>
</body>
</html>
提交的 dtfb_check.aspd补充里
dtfb_check.asp
<%
dim title,name_use,textarea,selec
title = Request.Form("title")
formUnitId = request.form("formUnitId")
formUserName= Request.Form("formUserName")
textarea = Request.Form("textarea")
'response.write lstb&"__"&lsts
'response.End()
Dim strSQL,objRS
strSQL = "SELECT * FROM news"
Set objRS=server.CreateObject("adodb.recordset")
objRS.open strSQL,Conn,1,3
objRS.addnew '添加一条新的记录到数据表末端
objRS("title") = title
objRS("selec") = formUnitId
objRS("name") = formUserName
objRS("addtim") = now()
objrs("content") = textarea
objRS.update
objRs.close
set objRS = nothing
call closeconn()
response.Write("<script language=javascript>alert ('发布成功!');location.href='../index.asp';</script>")
%> 展开
部门表是:province
nc_id(自动编号) nc_name(部门名称)(文本)
人员表名:use
id(自动编号) name(用户名)(文本) nc_upid(所属部门)
发布表名:news 怎么将二级联动菜单的发布部门和发布人的值存储到news表里的name ,selec字段里。代码如下:
<!--#include file="../config/db.ASP" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language = "JavaScript">
<%
dim count
set rs=server.createobject("ADODB.Recordset")
sql = "select * from use order by id asc"
rs.open sql,conn,1,1
%>
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= Left(rs("name"),10)%>","<%= trim(rs("nc_upid"))%>","<%= trim(rs("id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changeClass(locationid)
{
document.form1.formUserName.length = 0;
var locationid=locationid;
var i;
document.form1.formUserName.options[0] = new Option('-----请选择用户-----','');
for (i=0;i < onecount; i++)
{if (subcat[i][1] == locationid)
{
//alert(subcat[i][1]);
document.form1.formUserName.options[document.form1.formUserName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="../config/dtfb_check.asp" onSubmit="return check()">
<table width="776" border="1" align="center" cellpadding="0" cellspacing="0" background="../imager/bj.gif">
<tr>
<td height="30" colspan="6"><div align="center"><span class="style1 style4"><strong>发布工作动态</strong></span></div></td>
</tr>
<tr>
<td width="100" height="30"><div align="center"><span class="style3">工作动态标题:</span></div></td>
<td width="181"><input name="title" type="text" id="title"></td>
<td width="66"><div align="center"><span class="style3">发布部门:</span></div></td>
<td width="160">
<select name="formUnitId" onChange="changeClass(document.form1.formUnitId.options[document.form1.formUnitId.selectedIndex].value)">
<option value="" selected>-----请选择部门-----</option>
<% sql="select * from province order by nc_sort asc"
rs.open sql,conn,1,1
do while not rs.eof
%>
<option value="<%=rs("nc_name")%>"><%=rs("nc_name")%></option>
<% rs.movenext
loop
rs.close
%>
</select></td>
<td width="64"><div align="center"><span class="style3">发布人:</span></div></td>
<td width="191">
<select name="formUserName">
<option value="" selected>-----请选择用户-----</option>
</select></td>
</tr>
<tr>
<td><div align="center"><span class="style2 style3">工作动态内容:</span></div></td>
<td colspan="5"><span class="style3">
<textarea name="textarea" cols="89" rows="50"></textarea>
</span></td>
</tr>
<tr>
<td colspan="6"><div align="center">
<input type="submit" name="Submit" value="提交">
</div></td>
</tr>
</table>
</form>
</body>
</html>
提交的 dtfb_check.aspd补充里
dtfb_check.asp
<%
dim title,name_use,textarea,selec
title = Request.Form("title")
formUnitId = request.form("formUnitId")
formUserName= Request.Form("formUserName")
textarea = Request.Form("textarea")
'response.write lstb&"__"&lsts
'response.End()
Dim strSQL,objRS
strSQL = "SELECT * FROM news"
Set objRS=server.CreateObject("adodb.recordset")
objRS.open strSQL,Conn,1,3
objRS.addnew '添加一条新的记录到数据表末端
objRS("title") = title
objRS("selec") = formUnitId
objRS("name") = formUserName
objRS("addtim") = now()
objrs("content") = textarea
objRS.update
objRs.close
set objRS = nothing
call closeconn()
response.Write("<script language=javascript>alert ('发布成功!');location.href='../index.asp';</script>")
%> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询