[此贴子已经被作者于2006-11-23 12:11:46编辑过]
晕 拉。。。
你知道复选框传过来的值是一个用逗号分隔的字符串不?
象这样"1,3,5,7" 这样 你自己就不想想办法....
给你个例子 剩下的自己想 不要依赖别人
<%
a="3,4,6"
b=split(a,",")
for i=0 to UBound(b)
if i = 0 then m=b(i)
if i <>0 then m=m&","&b(i)
next
'response.Write(m)
m="("&m&")"
set rs= server.CreateObject("adodb.recordset")
sql = "select * from tab where id in "&m
'response.Write sql
rs.open sql,conn,1,1
do while not rs.eof
response.Write(rs("name")&"<br>")
rs.movenext
loop
%>
TO:做人很低调
我参考你的例案写的内容,可是提示是:
错误类型:
Microsoft JET Database Engine (0x80040E14)
(代码中红色部分)
请问我这里代码中哪个地方写错了,或还没有正确理解到你的意思。
<!--#include file="../Admin/Coon.asp" -->
<%
a=request.Form("id")
b=split(a,",")
for i=0 to UBound(b)
if i = 0 then m=b(i)
if i <>0 then m=m&","&b(i)
next
'response.Write(m)
m="("&m&")"
set rs= server.CreateObject("adodb.recordset")
sql = "select * from Products where M_id in "&m
'response.Write sql
rs.open sql,conn,1,1
%>
<table width="750" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td align="center"><strong>ITEM NO. </strong></td>
<td align="center"><strong>DESCRIPTION</strong></td>
<td align="center"><strong>QUANTITY</strong></td>
<td align="center"><strong>TOTAL AMONT </strong></td>
</tr>
<%do while not rs.eof%>
<tr>
<td align="center"><%=rs("M_ItemNo")%></td>
<td><%=rs("M_Desc")%></td>
<td align="center"><%=rs("M_Quan")%></td>
<td align="center">USD <%=rs("M_ToTa")%></td>
</tr>
<%
rs.movenext
loop%>
</table>
<%
rs.close
%>
JavaScript获取复选框的值进行传递也可以
<head>
<script language="JavaScript">
function Page_Submit()
{
for(var i=0;i<document.form1.ProID.length;i++)
{
if(document.form1.ProID[i].checked)
{
document.form1.PID.value=document.form1.ProID[i].value;
}
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="ch2.asp">
<table width="200" border="1">
<%set rs=server.CreateObject("adodb.recordset")
rs.open "select * from product",conn,1,1
while not rs.eof%>
<tr>
<td><input type="checkbox" name="ProID" value=<%=rs("id")%>><%=rs("username")%></td>
</tr>
<%rs.movenext
wend%>
<tr>
<td><input type="button" name="Submit" onClick="Page_Submit();" value="提交">
<input type="hidden" name="PID" >
</td>
</tr>
</table>
</form>
</body>
ch2.asp的接收代码
<%
'要注意的地方如果form表单的method="post"
'用以下语句才能接收到。
'id=request.form("PID")
id=request.querystring("PID")
set rs=server.createobject("adodb.recordset")
sql1="select * from product where id= "&id
rs.open sql1,coon,1,1
%>