新手求助!

seventhmm 2002-08-18 08:45:22

在form中有如下代码
<table>
<tr>
<td>
是否删除:<input type="checkbox" name="<%=rs("news_id")%>" value="off">
</td>
</tr>
</table>
其中rs是打开的记录集,news_id 是数据表中一字段
在转向页面中代码如下:
n=trim(cstr(rs("news_id")))
if request.form(n)="off"then
rs.delete
rs.update
end if
其他不必要的已省
运行后
其他都正常
但无论选与不选checkbox 都不能将其删除
怎么回事?
3x

--

...全文
68 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
seventhmm 2002-08-19
  • 打赏
  • 举报
回复
news_id在数据库中定义的就是整形
checkbox的name应当是字符型吧?
不知道name="<%=rs("news_id")%>"是否将其类型转换为字符型
lieejun 2002-08-19
  • 打赏
  • 举报
回复
光谢没用啊,给分哪,这么多人。
seventhmm 2002-08-19
  • 打赏
  • 举报
回复
谢谢大家的支持!
seventhmm 2002-08-19
  • 打赏
  • 举报
回复
哈哈
自己搞定!
caoshangfei 2002-08-18
  • 打赏
  • 举报
回复
n=trim(cstr(rs("news_id")))
改为n=cint(rs("news_id"))试试
caoshangfei 2002-08-18
  • 打赏
  • 举报
回复
n的值没有获得。。
caoshangfei 2002-08-18
  • 打赏
  • 举报
回复
我也建议换种写法。。
seventhmm 2002-08-18
  • 打赏
  • 举报
回复
我想不出别的写法!刚开始学!对语法还不是很熟!
cmsoft 2002-08-18
  • 打赏
  • 举报
回复
能不能换一种写法?@_@
seventhmm 2002-08-18
  • 打赏
  • 举报
回复
在加入checkbox的地方本来编码如第一篇帖子,不能删除,改为现在的形势
仍不能删除!据我测试,就是删除的那几条指令没有执行!可又不知怎样改!
seventhmm 2002-08-18
  • 打赏
  • 举报
回复

本网页全部代码如下:
<%
response.buffer=true
response.expires=0
%>
<!--#include file="data.inc"-->
<%
set rs=server.createobject("adodb.recordset")
sql="select * from data order by news_class asc,news_id desc"
'rs.pagesize=10
rs.open sql,conn,3,2
%>
<html>
<head>
<title>新闻数据库中所存的资料</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.lh22px{font-size:12px;line-height:22px;font-family:宋体}
a{text-decoration:none}
body{line-height:18px;font-size:9px;font-family:宋体}
td{line-height:18px;font-size:9px;font-family:宋体}
a:hover{color:#ff0000;text-decoration:none}
-->
</style>
<meta name="microsoft border"content="none">
</head>

<body>
<form name="form1" method="post" action="delete.asp">
<table width="750" border="0"cellpadding="0">
<tr>
<td width="750"bgcolor="#ebebeb"colspan="2"><div align="center">
<center><p><font size="3"><strong>新闻数据库中所存的资料</strong></font></center></div>
</td>
</tr>
<%
do while not rs.eof
%>
<tr align="center">
<td width="112"bgcolor="#ebebeb">是否删除:
<%
name1=rs("news_id")
name1=trim(cstr(name1))
%>
<input type="checkbox" name=<%=&name1%> value="off" >

</td>
<td width="638"bgcolor="#fafafa"align="left"><%if rs("news_class")=1 then %>
<font color=red>市场风云</font>
<%end if%>
<%if rs("news_class")=2 then%>
<font color=red>IT新闻</font>
<%end if %>
<%if rs("news_class")=3 then %>
<font color=red>广州市场</font>
<%end if %>
<%if rs("news_class")=4 then %>
<font color=red>保留</font>
<%end if %>
<%=rs("news_title")%>
</td>
</tr>
<%
rs.movenext
loop
%>
<tr align="center">
<td width="100%"colspan="2" bgcolor="#ebebeb"><center>
<p><input type="submit"value="提交"name="b1">
<input type="reset" value="清除"name="b2"></center></td>
</tr>
</table>
</form>

</body>
</html>
<%
if request.servervariables("request_method")="post" then
if not rs.bof then
rs.movefirst
end if

do while not rs.eof
n=trim(cstr(rs("news_id")))
if request.form(n).value="off" then
rs.delete
rs.update
end if
rs.movenext
loop
response.redirect "delete.asp"
rs.close
end if
response.flush
%>
luerdong 2002-08-18
  • 打赏
  • 举报
回复
1. Form"<%=rs("news_id")%>"提交方式是否为Post
2. 数据库不能以只读方式打开
caoshangfei 2002-08-18
  • 打赏
  • 举报
回复
你把全部的代码贴出来看看啊。。
seventhmm 2002-08-18
  • 打赏
  • 举报
回复
数据库连接没问题
因为能检索出数据库的内容并显示
就是不能删除
是不是checkbox的问题?
xfyz 2002-08-18
  • 打赏
  • 举报
回复
数据库链接是否忘了?
caoshangfei 2002-08-18
  • 打赏
  • 举报
回复
你打开数据表了吗?

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧