请教:怎样保存留言格式:换行、空格

beginner123 2004-03-19 02:06:03
我做一个简单留言版,留言内容放在sql server里,类型为text,
请问怎样才能保存留言时的格式,包括换行、空格等。
谢谢!
...全文
155 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunny911 2004-03-19
  • 打赏
  • 举报
回复
message= replace(message," "," ") 换空格
message= replace(message, vnbcrlf, <br>") 换回车
gjd111686 2004-03-19
  • 打赏
  • 举报
回复
<div align=left id=App style="background-color:#F7F7F7;height:380px;overflow:auto;width:100%;z-index:2" contentEditable></div>
将App.innerHTML赋给表单域提交后
注意插入数据库必须用AddNew方法,直接用Insert插入需要处理符号,用AddNew就不用了.
rehearts 2004-03-19
  • 打赏
  • 举报
回复
function coder(str)
if not isnull(str) then
str=replace(str, ">", ">")
str=replace(str, "<", "<")

str = replace(str, chr(32), " ")
str = replace(str, chr(9), " ")
str = replace(str, chr(34), """)
str = replace(str, chr(39), "'")
str = replace(str, chr(13), "")
str = replace(str, chr(10) & chr(10), "</P><P> ")
str = replace(str, chr(10), "<BR> ")

coder=str
end if
end function

使用方法:
aaa=coder(request("字段名"))
feilong4397 2004-03-19
  • 打赏
  • 举报
回复
换行用〈br>
空格用 代替
chuanyuan88 2004-03-19
  • 打赏
  • 举报
回复
用replace函数
sfply 2004-03-19
  • 打赏
  • 举报
回复
function HTMLEncode(fString)
fString = replace(fString,">", ">")
fString = replace(fString,"<", "<")
fString = replace(fString,CHR(13) & CHR(10), "<br>")
fString = replace(fString,"'", "")
fString = Replace(fString,CHR(13), " ")
fString = Replace(fString," ", " ")
HTMLEncode = fString
end function
使用时加
response.write HTMLEncode(rs("..."))
popcode 2004-03-19
  • 打赏
  • 举报
回复
replace
kellybs 2004-03-19
  • 打赏
  • 举报
回复
保存的时候:
function changechr(str)
changechr=replace(replace(str,vbcrlf,"<br>")," "," ")
end function

显示的时候:

function changechr(str)
changechr=replace(replace(str,"<br>",vbcrlf)," "," ")
end function
mikespook 2004-03-19
  • 打赏
  • 举报
回复
将空格替换为 
将换行替换为<br>就可以了~~

给你一个我用了好几年的函数~~呵呵~~好用~~~

<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case "'"
result=result+"´"
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>
xkou 2004-03-19
  • 打赏
  • 举报
回复
<textarea name="textarea" wrap="VIRTUAL"></textarea>
就可以保存格式,主要输出的时候控制就可以.
  • 打赏
  • 举报
回复
通过htmlencode(request.form(textarea))

28,404

社区成员

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

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