哪位大哥帮我看下,for循环执行不了,只能执行一条记录,跪谢。


cust_list.asp页面中的代码如下:

function del(){ var num=document.getElementById("ckcount"); if(num.innerHTML=="0") { alert('至少要选择一条记录') } else{ if(confirm('确定要删除该表资料吗?')) { var number=document.getElementById("hiddnum"); for(e=0;e<number.value;e++) {if (document.getElementById("custom"+e).checked==true) { document.write(document.getElementById("custom"+e).value); } else{} } } } }



<%
set rs=server.createobject("adodb.recordset")
if request("action")="del" then
sql="select * from t_custom where id="&request("id")
rs.open sql,conn,1,1
company=rs("company")
sql="delete from t_contact where company='"&company&"'"
conn.execute sql
sql="delete from t_custom where id="&request("id")
conn.execute sql
response.write "location.href=&#39;cust_list.asp&#39;"
end if

%>

删除

public.asp页面中的代码如下:

<%
For i = 0 To rs.pagesize -1
If rs.bof Or rs.EOF Then Exit For
%>


我现在想实现全选删除cust_list.asp页面中的记录,可是只能删除一条,求哪位大哥帮忙看下,我不是太懂的。谢谢了。

1.number.value 先确定number.value的值是否是大于1的数字
2.将number.value转换为number,
3.document.getElementById("custom"+e) 是不是你需要的对象

随便用个浏览器,F12.

number.value,检查这个值是啥

除去你的客户端的代码问题,你的服务器端代码有一个重要问题就是遍历客户端发送过来的request。你直接用request("id"),这样只获取了一个值,删除的自然是一条记录。其实request是一个集合。
参考ASP教程:第七篇 ASP内建对象Request
不管是Request.Form还是Request.QueryString,你都可以遍历,比如
For i = 1 To Request.Form("id").Count或者For Each i In Request.querystring("id") ,这样才能把所有客户端传过来的id取得,再通过相应的代码去删除。

除去你的客户端的代码问题,你的服务器端代码有一个重要问题就是遍历客户端发送过来的request。你直接用request("id"),这样只获取了一个值,删除的自然是一条记录。其实request是一个集合。
参考ASP教程:第七篇 ASP内建对象Request
不管是Request.Form还是Request.QueryString,你都可以遍历,比如
For i = 1 To Request.Form("id").Count或者For Each i In Request.querystring("id") ,这样才能把所有客户端传过来的id取得,再通过相应的代码去删除。