删除 出错(菜鸟求助)

fange008 2007-09-05 05:40:29
<script language="javascript" src="../include/js.js"></script>
<link href="../include/iframe.css" rel="stylesheet" type="text/css" />

<!--#include file="../db/conn.asp" -->
<%
function del(temp)
sql_del="delete from a where id="&temp
conn.execute sql_del,,adcmdtext+adexecutenorecords
response.write "<script>alert('删除成功!');window.location.reload();</script>"
end function
%>
<div id="div_div">
<div id="contents">
<fieldset>
<legend>规章制度</legend>
<br />
<%
sql="select * from a where type='"&"规章制度"&"' order by adddate desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<p>暂无规章制度</p>"
else
dim i
i=1
do while not rs.eof and i<=10
%>
<span class="title"><%=i%>.<%=rs("title")%></span>
<span class="date">(<%=rs("adddate")%>)</span>
<span class="delete">修改</span>
<span class="delete" onclick="del(<%=rs("id")%>)">删除</span>
<br />
<%
rs.movenext
i=i+1
loop
end if

rs.close
set rs=nothing
conn.close
set rs=nothing
%>
<br />
</fieldset>
</div>
</div>

<style type="text/css">
#contents{
position:relative;
width:80%;
margin-top:50px;
}
.title{
padding:0px;
margin-left:25px;
cursor:pointer;
font-size:14px;
color:red;
float:left;
height:22px;
}
.delete{
padding:0px;
margin-left:10px;
cursor:pointer;
font-size:14px;
color:#666666;
float:left;
height:22px;
}
.date{
padding:0px;
margin-left:10px;
font-size:14px;
color:#cccccc;
float:left;
height:22px;
}
</style>
========================================
什么地方错了
...全文
132 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
fange008 2007-09-05
  • 打赏
  • 举报
回复
<script language="javascript" src="../include/js.js"></script>
<link href="../include/iframe.css" rel="stylesheet" type="text/css" />

<!--#include file="../db/conn.asp" -->
<%
action=request("action")
if action="remove" then
id=request("id")
if not isnumeric(id) then
repsonse.write "非法请求,拒绝访问"
response.end
end if
del(id)
end if
function del(temp)
sql_del="delete from a where id="&temp
conn.execute sql_del,,adcmdtext+adexecutenorecords
url=Request.ServerVariables("HTTP_REFERER")
response.write "<script>alert('删除成功!');window.location.href='"&url&"';</script>"
end function
%>
<div id="div_div">
<div id="contents">
<fieldset>
<legend>规章制度</legend>
<br />
<%
sql="select * from a where type='"&"规章制度"&"' order by adddate desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<p>暂无规章制度</p>"
else
dim i
i=1
do while not rs.eof and i<=10
%>
<span class="title"><%=i%>.<%=rs("title")%></span>
<span class="date">(<%=rs("adddate")%>)</span>
<span class="delete">修改</span>
<span class="delete"><a href="?action=remove&id=<%=rs("id")%>">删除</a></span>
<br />
<%
rs.movenext
i=i+1
loop
end if

rs.close
set rs=nothing
conn.close
set rs=nothing
%>
<br />
</fieldset>
</div>
</div>

<style type="text/css">
#contents{
position:relative;
width:80%;
margin-top:50px;
}
.title{
padding:0px;
margin-left:25px;
cursor:pointer;
font-size:14px;
color:red;
float:left;
height:22px;
}
.delete{
padding:0px;
margin-left:10px;
cursor:pointer;
font-size:14px;
color:#666666;
float:left;
height:22px;
}
.date{
padding:0px;
margin-left:10px;
font-size:14px;
color:#cccccc;
float:left;
height:22px;
}
</style>


============
搞定了,谢谢各位
fange008 2007-09-05
  • 打赏
  • 举报
回复
Microsoft VBScript 编译器错误 错误 '800a0408'

无效字符

/oa/a/a_1.asp,行18

response.write "<script>alert('删除成功!');window.location.reload("?action=");</script>"
-----------------------------------------------------------^
fange008 2007-09-05
  • 打赏
  • 举报
回复
多谢谢啊,
No_Data_Found 2007-09-05
  • 打赏
  • 举报
回复
楼上很有耐心 佩服
什么都不能 2007-09-05
  • 打赏
  • 举报
回复
上面的代码应该够详细了,楼主还要详细的代码。。。。。
Atai-Lu 2007-09-05
  • 打赏
  • 举报
回复
呃,不好意思,写错了...
回复人:hanpoyangtitan(韩波洋) ( 两星(中级)) 信誉:100
的修改是正确的
Atai-Lu 2007-09-05
  • 打赏
  • 举报
回复
<span class="delete" onclick="del(<%=rs("id")%>)">删除</span>
===>>
<a href="?menu=del">删除</a>
=======================
<%
if request("menu")="del" then
sql_del="delete from a where id="&temp
conn.execute sql_del
response.write "<script>alert('删除成功!');window.location.reload();</script>"
end function
end if
%>
fange008 2007-09-05
  • 打赏
  • 举报
回复
呵呵,有没有详细的代码?
什么都不能 2007-09-05
  • 打赏
  • 举报
回复
救急看这里
<script language="javascript" src="../include/js.js"></script>
<link href="../include/iframe.css" rel="stylesheet" type="text/css" />

<!--#include file="../db/conn.asp" -->
<%
action=request("action")
if action="remove" then
id=request("id")
if not isnumeric(id) then
repsonse.write "非法请求,拒绝访问"
response.end
end if
del(id)
end if
function del(temp)
sql_del="delete from a where id="&temp
conn.execute sql_del,,adcmdtext+adexecutenorecords
response.write "<script>alert('删除成功!');window.location.reload("?action=");</script>"
end function
%>
<div id="div_div">
<div id="contents">
<fieldset>
<legend>规章制度</legend>
<br />
<%
sql="select * from a where type='"&"规章制度"&"' order by adddate desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<p>暂无规章制度</p>"
else
dim i
i=1
do while not rs.eof and i<=10
%>
<span class="title"><%=i%>.<%=rs("title")%></span>
<span class="date">(<%=rs("adddate")%>)</span>
<span class="delete">修改</span>
<span class="delete"><a href="?action=remove&id=<%=id %>">删除</a></span>
<br />
<%
rs.movenext
i=i+1
loop
end if

rs.close
set rs=nothing
conn.close
set rs=nothing
%>
<br />
</fieldset>
</div>
</div>

<style type="text/css">
#contents{
position:relative;
width:80%;
margin-top:50px;
}
.title{
padding:0px;
margin-left:25px;
cursor:pointer;
font-size:14px;
color:red;
float:left;
height:22px;
}
.delete{
padding:0px;
margin-left:10px;
cursor:pointer;
font-size:14px;
color:#666666;
float:left;
height:22px;
}
.date{
padding:0px;
margin-left:10px;
font-size:14px;
color:#cccccc;
float:left;
height:22px;
}
</style>
toury 2007-09-05
  • 打赏
  • 举报
回复
当然不可以,你用客户端函数命令怎么可以直接操纵删除SERVER端的记录呢,呵呵

用表单
<form.............name='frm'>
<span class="delete" onclick="javascript:frm.submit();">删除</span>
<input type=hidden name="del_id" value="<%=rs("id")%>">
</form>
什么都不能 2007-09-05
  • 打赏
  • 举报
回复
建议楼主买本asp的初级读物先看看,弄清楚asp的工作模式再说。
fange008 2007-09-05
  • 打赏
  • 举报
回复
错误提示

JAVASCRIPT 的,

缺少对象,不知道是什么对象
fange008 2007-09-05
  • 打赏
  • 举报
回复
还是不行,直接写成onclick="del(1)" 也出错!
fange008 2007-09-05
  • 打赏
  • 举报
回复
<span class="delete" onclick="del(<%=rs("id")%>)">删除</span>
onclick似乎只能调用客户端的函数...
你的del函数是服务器端的函数


估计是这个问题,不知道怎么改?
Atai-Lu 2007-09-05
  • 打赏
  • 举报
回复
什么结果?
不能删除?还是运行错误?
好像是不能删除吧?
<span class="delete" onclick="del(<%=rs("id")%>)">删除</span>
onclick似乎只能调用客户端的函数...
你的del函数是服务器端的函数
jingxiaoping 2007-09-05
  • 打赏
  • 举报
回复
conn.execute sql_del,,adcmdtext+adexecutenorecords
改成
conn.execute sql_del
试试

28,390

社区成员

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

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