asp代码为什么批量修改不了数据?
目前只是测试修改功能就实现不了。大家帮我看看,谢谢~第一个a.asp页面代码:<scriptlanguage=javascript>functionunselectall...
目前只是测试修改功能就实现不了。大家帮我看看,谢谢~
第一个a.asp页面代码:
<script language=javascript>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><%
do while not rs.eof
%>
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request("delid") & ""="" then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
arrdel=Request("delid")
basket_count=Request("basket_count")
thcount=Request("thcount")
for i=1 to arrdel.count
sql="update venshop_basket set basket_count='" & thcount(i) & "' where basket_id='" & arrdel(i) & "'"
conn.Execute sql
next
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%> 展开
第一个a.asp页面代码:
<script language=javascript>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><%
do while not rs.eof
%>
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request("delid") & ""="" then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
arrdel=Request("delid")
basket_count=Request("basket_count")
thcount=Request("thcount")
for i=1 to arrdel.count
sql="update venshop_basket set basket_count='" & thcount(i) & "' where basket_id='" & arrdel(i) & "'"
conn.Execute sql
next
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%> 展开
1个回答
展开全部
<script language=javascript>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><%
do while not rs.eof
%>
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount<%=cstr(rs("basket_id"))%>" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request("delid") & ""="" then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
basket_count=Request("basket_count")
thcount=Request("thcount")
id=request("delid") '获取的ID值如: id=1, 3
nid=split(id,", ") ' 根据逗号把id分割,返回数组nid
sid=ubound(nid) '得到几个值
for i = 0 to sid 'nid(i)就是要操作的id,并做循环更新记录
sql="update venshop_basket set basket_count='" & thcount(nid) & "' where basket_id='" & nid(i) & "'"
conn.Execute sql
next
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><%
do while not rs.eof
%>
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount<%=cstr(rs("basket_id"))%>" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request("delid") & ""="" then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
basket_count=Request("basket_count")
thcount=Request("thcount")
id=request("delid") '获取的ID值如: id=1, 3
nid=split(id,", ") ' 根据逗号把id分割,返回数组nid
sid=ubound(nid) '得到几个值
for i = 0 to sid 'nid(i)就是要操作的id,并做循环更新记录
sql="update venshop_basket set basket_count='" & thcount(nid) & "' where basket_id='" & nid(i) & "'"
conn.Execute sql
next
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询