读书人

asp复选框选中的行的值安插另一张表中

发布时间: 2013-03-01 18:33:02 作者: rapoo

asp复选框选中的行的值插入另一张表中
复选框的代码是<input id="ck" name="ck" type="checkbox" value='<%=rs("id")%>'>

接下来想在点击“确认提交”按钮之后把选中的行数据插入到kbf_mx这张表里,请各位牛人为小弟解答,谢谢。

下面是框架的代码。

引用
<!--#include file="../inc/NoCatch.asp"-->
<!--#include file="../inc/Secure.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Const.asp"-->
<!--#include file="../inc/fun.asp" -->
<%
'------------------------------------------------设置参数
LoginID=trim(Session("LoginID")) : if LoginID="" then LoginID=0 '当前用户ID
lodindep=getuser("tbioaUser",LoginID,"department","未知")

maxmessage=200 '每页显示记录数
currentpage=request("page") '当前页码
Search=request("Search") '上次查询条件

set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from kbfqd"
rs.open sql,oConn,1,1

Showpage=Paging(rs,maxmessage,currentpage,"Search="&Server.URLEncode(Search))
'------------------------------------------------处理记录
%>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css/main.css" type=text/css>
<title>main</title>
<base target="topFrame">
<script language="javascript">
function checkAll(boolValue)
{
var allcheck=document.getElementsByName("ck");
for(var i=0;i<allcheck.length;i++)
if(allcheck[i].type=="checkbox")
allcheck[i].checked=boolValue;
}
function selectAll()
{
var checkbox1=document.getElementById("ckall");
if(checkbox1.checked==true )
{
checkAll(true);
}
else
{
checkAll(false);
}
}

</script>

<script language="vbscript">
function ischecked(obj)
for i = 0 to obj.length-1
if obj(i).checked then ischecked = true : exit function
next
ischecked = false
end function

function chk()
dd=form1.ck.length
if ischecked(form1.ck)=false then
alert("未选择任何项目!!!")
return false
exit function
end if
end function
</script>
<style type="text/css">
<!--
.STYLE2 {color: #0000FF}
-->
</style>
</head>

<body topmargin="0" leftmargin="0" >
<form name="eventfrm" method="POST" action="" onSubmit="return require(this)">
<%=Showpage%>
<br>
<%
if rs.RecordCount=0 then
response.write "<BR><BR>暂时为空!"
else
count=1
%>
<table width="780" border="0" cellpadding="1" cellspacing="1" class="tab">
<tr>
<td width="30" nowrap class="tdTop"><div align="center">序号</div></td>
<td width="60" nowrap class="tdTop"><div align="center">项目编号</div></td>
<td width="250" nowrap class="tdTop"><div align="center">供应</div></td>
<td width="140" nowrap class="tdTop"><div align="center">项目</div></td>


<td width="270" nowrap class="tdTop"><div align="center">备注</div></td>
<td width="30" nowrap class="tdTop"><div align="center"><input id="ckall" name="ckall" type="checkbox" onClick="selectAll()"></div></td>
</tr>
<%
for c = 0 to rs.PageSize-1
If rs.EOF Then Exit For
if c mod 2 = 0 then td_class="td1" else td_class="td2"
%>
<tr>
<td class="<%=td_class%>"><div align="center" class="STYLE2"><%=count%></div></td>
<td class="<%=td_class%>"><div align="center"><%=rs("id")%></div></td>
<td class="<%=td_class%>"><div align="center"><%=rs("parunit")%></div></td>
<td class="<%=td_class%>"><div align="center"><%=rs("xm")%></div></td>
<td class="<%=td_class%>"><div align="center">
</div></td>
<td class="<%=td_class%>"><div align="center">
<input id="ck" name="ck" type="checkbox" value='<%=rs("id")%>'>
</div></td>
</tr>
<%
rs.MoveNext
count=count+1
next
%>
</table>
<table width="780" border="0" cellpadding="1" cellspacing="1" class="button">
<tr>
<td>
<div align="right">
<input type="submit" name="subed" value="确认提交" onClick="return check()">
<input type="reset" name="b22" value="全部重写">
</div></td>
</tr>
</table>
<%
end if
rs.close
%>
</p>
</div>
</form>
</body>
</html>
<%'释放对象变量
oConn.close
%>

asp 复选框
[解决办法]
<%
...
id=request.from("ck")
sql="insert into table1 select * from table2 where id in ("&id&")"
conn.execute(sql)
...
%>

读书人网 >ASP

热点推荐