replace(内容,chr(10)&chr(13),
)这句话应该放到那里!

internet007 2002-04-22 04:31:03
我做了一个留言本的程序,知道了怎么样令内容回车的语句。但不知道它应该放到那里!请各位指点一下!

我的程序如下:

<!--#include file="../conn.asp"-->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>查看留言</title>
<link rel="stylesheet" href="../css/css02.css" type="text/css">
<style type="text/css">
</style>
</head>

<body bgColor=#006699 >
<SCRIPT language=JavaScript>
function closewin() {window.close(); return;}
</SCRIPT>



<%
set rs=server.createobject("adodb.recordset")
sql="select * from photo where id=" & request.querystring("id")
rs.open sql,conn,3,1
%>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td width="12%">
<p align="center"><font color="#FFFFFF" size="2" face="黑体" ><b>作者:</b></font></p>
</td>
<center>
<td width="20%"><b><font color="#FFFF00" size="2" face="宋体"><p align="left"><%=rs("名字") %></font></b></td>
<td width="17%"><p align="right"><b><font color="#FFFFFF" face="黑体" size="2">E-MAIL(电子邮件):</font></b></td>
<td width="17%"><p align="left"><b><font color="#FFFF00" size="2" face="宋体"><a href="mailto:<%=rs("地址") %>"><%=rs("地址") %></a></font></b></td>
</center>
<td width="17%">
<p align="right"><b><font color="#FFFFFF" size="2" face="黑体">留言时间:</font></b></td>
<center>
<td width="17%"><b><font color="#FFFF00" size="2" face="宋体"><p align="center"><%=rs("时间") %></font></b></td>
</tr>
</table>
</center>
</div>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td width="100%" colspan="2" height="20"></td>
</tr>
<tr>
<td width="12%">
<p align="center"><b><font color="#FFFFFF" size="2" face="黑体">主题:</font></b></td>
<center>
<td width="88%"><b><font color="#FFFF00" size="2" face="宋体"><p align="left"><%=rs("标题") %> </font></b></td>
</tr>
</table>
</center>
</div>

<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td width="100%" height="20">
<p align="center"></td>
</tr>
<tr>
<td width="100%">
<p align="center"><font size="3" color="#FFFFFF" face="黑体">留 
言  内  容</font></td>
</tr>
</table>
</center>
</div>



<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="90%" height="30">
<tr>
<td width="100%"></td>
</tr>
<tr>
<td width="100%">
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" width="60%" bordercolor="#FFFFFF">
<tr>
<td width="100%"><b><font color="#FFFFFF" size="2" face="宋体"><h3><%=rs("内容") %></h3></font></b>  </td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</center>
</div>

<p align="center"><a href="javascript:closewin();">关闭窗口</a></p>

</body>

</html>
...全文
683 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Arthurz 2002-04-22
  • 打赏
  • 举报
回复
在表单内数据提交时,处理存储数据库的时候用
以下是我以前写的代码
function changechr(str)
changechr=replace(replace(replace(replace(str,"<","<"),">",">"),chr(13),"<br>")," "," ")
changechr=replace(replace(replace(replace(changechr,"[pic]","<center><img src="),"","<b>"),"[red]","<font color=CC0000>"),"[big]","<font size=7>")
changechr=replace(replace(replace(replace(changechr,"[/pic]","></img></center>"),"
","</b>"),"[/red]","</font>"),"[/big]","</font>")
end function

你只要改一下,把不需要的去掉,就可用了
content=request("内容")
changechr(content)
然后再添加到数据库里

不好意思,你的代码太长,我看得眼花,你就套用这个格式就可以了,希望对你有帮助
internet007 2002-04-22
  • 打赏
  • 举报
回复
试过啦!但还是不行呀!究竟是那里出了问题?
internet007 2002-04-22
  • 打赏
  • 举报
回复
哦!让我试试!
longxiaojie 2002-04-22
  • 打赏
  • 举报
回复
看错了,不好意思!就应该:
up的
content=replace(request.form("s1"),chr(10)&chr(13),"<br>")'------------我加到这里可以吗?
改成:
content=replace(request.form("s1"),chr(10),"<br>")'------------我加到这里可以吗?

改这个就行了,因为回车符加一次到数据库就行了,显示的时候就不用替换了
不过如果是修改的话就需要逆向替换!
longxiaojie 2002-04-22
  • 打赏
  • 举报
回复
up的
content=replace(request.form("s1"),chr(10)&chr(13),"<br>")'------------我加到这里可以吗?
改成:
content=replace(request.form("s1"),chr(10),"<br>")'------------我加到这里可以吗?

另外你的第一个页面应该是修改留言吧?哪就应该是逆向替换:
<%=rs("内容") %>变为
<%=replace(rs("内容"),"<br>","ch(10)")%>


internet007 2002-04-22
  • 打赏
  • 举报
回复
<!--#include file="../conn.asp"-->
<%
dim rs
dim sql
dim name01
dim type01
dim address01
dim title01
dim time01
set rs=server.createobject("adodb.recordset")
set name01=request.form("name")
set address01=request.form("email")
set type01=request.form("s1")
set title01=request.form("title")
time01=now
response.write "<html>"
response.write "<head></head>"
response.write "<body bgColor=#006699 >"
response.write "<table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">"
if(name01="" or type01="" or address01="" or title01="" ) then
response.write "<tr><td width=""100%"" align=""center""><font color=""#FFFF00"" face=""楷体_GB2312"" size=""2""><b>添加数据失败!</b></font></td></tr>"
response.write "<tr><td width=""100%"" align=""center""><font color=""#FFFFFF"" face=""楷体_GB2312"" size=""2""><b>姓名、E-MAIL(电子邮件)、主题、留言,以上四项内容不能为空</b></font></td></tr>"
response.write "<tr><td width=""100%"" align=""center""><input type=""button"" name=""submit"" value=""重新填写"" onclick=""javascript:top.location='../topic/topic.htm'"">"
response.write "</td></tr></table></body></html>"
response.end
elseif instr(address01,"@") = 0 then
response.write "<tr><td width=""100%"" align=""center""><font color=""#FFFFFF"" face=""楷体_GB2312"" size=""2""><b>你输入了一个无效的E-MAIL地址</b></font></td></tr>"
response.write "<tr><td width=""100%"" align=""center""><input type=""button"" name=""submit"" value=""重新填写"" onclick=""javascript:top.location='../topic/topic.htm'"">"
response.write "</td></tr></table></body></html>"
response.end
elseif instr(address01,".") = 0 then
response.write "<tr><td width=""100%"" align=""center""><font color=""#FFFFFF"" face=""楷体_GB2312"" size=""2""><b>你输入了一个无效的E-MAIL地址</b></font></td></tr>"
response.write "<tr><td width=""100%"" align=""center""><input type=""button"" name=""submit"" value=""重新填写"" onclick=""javascript:top.location='../topic/topic.htm'"">"
response.write "</td></tr></table></body></html>"
response.end
else
content=replace(request.form("s1"),chr(10)&chr(13),"<br>")'------------我加到这里可以吗?
sql="insert into photo(名字,地址,标题,内容,时间) values('"&name01&"','"&address01&"','"&title01&"','"&content&"','"&time01&"')"
conn.execute(sql)
response.write "<tr><td width=""100%"" align=""center""><font color=""#FFFF00"" face=""楷体_GB2312"" size=""2""><b>成功添加记录!</b></font></td></tr>"
response.write "<tr><td width=""100%"" align=""center""><input type=""button"" name=""submit"" value=""返回"" onclick=""javascript:top.location='../topic/list.asp'"">"
response.write "</td></tr></table></body></html>"
response.end
end if
%>

我加到那个位置可以吗?但我试过还是不行!
希偌 2002-04-22
  • 打赏
  • 举报
回复
content=replace(rs("内容"),chr(10)&chr(13),"<br>")
在写入数据库之前或显示于页面之前
希偌 2002-04-22
  • 打赏
  • 举报
回复
content=replace(rs("内容"),chr(10)&chr(13),"<br>")
在写入数据库之前或显示于页面之前
internet007 2002-04-22
  • 打赏
  • 举报
回复
TO:bbschat
我试过你的方法,但还是不能换行!
bbschat 2002-04-22
  • 打赏
  • 举报
回复
<%=rs("内容") %>变为

<%=replace(rs("内容"),"chr(13)","<br>")

28,390

社区成员

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

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