ASP里面解决字符串换行

我从表单textarea里面读取数据写到数据库里,然后又显示到页面上,在“<td>”里面,可是字符串不会换行~~问问大家用什么办法,才能让他输出的时候自动换行限制了也不行... 我从表单textarea里面读取数据写到数据库里,然后又显示到页面上,在“<td>”里面,可是字符串不会换行~~问问大家用什么办法,才能让他输出的时候自动换行
限制了也不行啊,还是不行,是不是在表单读取的时候就要转换???
参数 howmany 是什么意思?
展开
 我来答
帐号已注销
2006-08-26
知道答主
回答量:9
采纳率:0%
帮助的人:0
展开全部
上面说的方法仅仅只针对用户输入的内容有回车的情况,如果别人直接写,而不换行,上面的两种方法就不灵了,给你一段代码就可以解决这个问题,并且可以解决英文字母撑破表格的现象:

1:字符串格式化:
-------------------
<%
function EchoFormat(echofield,howmany)
arrstr=split(echofield,chr(13))
for intIci=0 to UBound(arrstr)
arrstr(intIci)=Replace(arrstr(intIci),"A","A")
arrstr(intIci)=Replace(arrstr(intIci),"B","B")
arrstr(intIci)=Replace(arrstr(intIci),"C","C")
arrstr(intIci)=Replace(arrstr(intIci),"D","D")
arrstr(intIci)=Replace(arrstr(intIci),"E","E")
arrstr(intIci)=Replace(arrstr(intIci),"F","F")
arrstr(intIci)=Replace(arrstr(intIci),"G","G")
arrstr(intIci)=Replace(arrstr(intIci),"H","H")
arrstr(intIci)=Replace(arrstr(intIci),"I","I")
arrstr(intIci)=Replace(arrstr(intIci),"J","J")
arrstr(intIci)=Replace(arrstr(intIci),"K","K")
arrstr(intIci)=Replace(arrstr(intIci),"L","L")
arrstr(intIci)=Replace(arrstr(intIci),"M","M")
arrstr(intIci)=Replace(arrstr(intIci),"N","N")
arrstr(intIci)=Replace(arrstr(intIci),"O","O")
arrstr(intIci)=Replace(arrstr(intIci),"P","P")
arrstr(intIci)=Replace(arrstr(intIci),"Q","Q")
arrstr(intIci)=Replace(arrstr(intIci),"R","R")
arrstr(intIci)=Replace(arrstr(intIci),"S","S")
arrstr(intIci)=Replace(arrstr(intIci),"T","T")
arrstr(intIci)=Replace(arrstr(intIci),"U","U")
arrstr(intIci)=Replace(arrstr(intIci),"V","V")
arrstr(intIci)=Replace(arrstr(intIci),"W","W")
arrstr(intIci)=Replace(arrstr(intIci),"X","X")
arrstr(intIci)=Replace(arrstr(intIci),"Y","Y")
arrstr(intIci)=Replace(arrstr(intIci),"Z","Z")

arrstr(intIci)=Replace(arrstr(intIci),"a","a")
arrstr(intIci)=Replace(arrstr(intIci),"b","b")
arrstr(intIci)=Replace(arrstr(intIci),"c","c")
arrstr(intIci)=Replace(arrstr(intIci),"d","d")
arrstr(intIci)=Replace(arrstr(intIci),"e","e")
arrstr(intIci)=Replace(arrstr(intIci),"f","f")
arrstr(intIci)=Replace(arrstr(intIci),"g","g")
arrstr(intIci)=Replace(arrstr(intIci),"h","h")
arrstr(intIci)=Replace(arrstr(intIci),"i","i")
arrstr(intIci)=Replace(arrstr(intIci),"j","j")
arrstr(intIci)=Replace(arrstr(intIci),"k","k")
arrstr(intIci)=Replace(arrstr(intIci),"l","l")
arrstr(intIci)=Replace(arrstr(intIci),"m","m")
arrstr(intIci)=Replace(arrstr(intIci),"n","n")
arrstr(intIci)=Replace(arrstr(intIci),"o","o")
arrstr(intIci)=Replace(arrstr(intIci),"p","p")
arrstr(intIci)=Replace(arrstr(intIci),"q","q")
arrstr(intIci)=Replace(arrstr(intIci),"r","r")
arrstr(intIci)=Replace(arrstr(intIci),"s","s")
arrstr(intIci)=Replace(arrstr(intIci),"t","t")
arrstr(intIci)=Replace(arrstr(intIci),"u","u")
arrstr(intIci)=Replace(arrstr(intIci),"v","v")
arrstr(intIci)=Replace(arrstr(intIci),"w","w")
arrstr(intIci)=Replace(arrstr(intIci),"x","x")
arrstr(intIci)=Replace(arrstr(intIci),"y","y")
arrstr(intIci)=Replace(arrstr(intIci),"z","z")

arrstr(intIci)=Replace(arrstr(intIci),"`","‘")
arrstr(intIci)=Replace(arrstr(intIci),"1","1")
arrstr(intIci)=Replace(arrstr(intIci),"2","2")
arrstr(intIci)=Replace(arrstr(intIci),"3","3")
arrstr(intIci)=Replace(arrstr(intIci),"4","4")
arrstr(intIci)=Replace(arrstr(intIci),"5","5")
arrstr(intIci)=Replace(arrstr(intIci),"6","6")
arrstr(intIci)=Replace(arrstr(intIci),"7","7")
arrstr(intIci)=Replace(arrstr(intIci),"8","8")
arrstr(intIci)=Replace(arrstr(intIci),"9","9")
arrstr(intIci)=Replace(arrstr(intIci),"0","0")
arrstr(intIci)=Replace(arrstr(intIci),"-","-")
arrstr(intIci)=Replace(arrstr(intIci),"=","=")
arrstr(intIci)=Replace(arrstr(intIci),"\","\")

arrstr(intIci)=Replace(arrstr(intIci),"~","~")
arrstr(intIci)=Replace(arrstr(intIci),"!","!")
arrstr(intIci)=Replace(arrstr(intIci),"@","@")
arrstr(intIci)=Replace(arrstr(intIci),"#","#")
arrstr(intIci)=Replace(arrstr(intIci),"$","$")
arrstr(intIci)=Replace(arrstr(intIci),"%","%")
arrstr(intIci)=Replace(arrstr(intIci),"^","^")
arrstr(intIci)=Replace(arrstr(intIci),"&","&")
arrstr(intIci)=Replace(arrstr(intIci),"*","*")
arrstr(intIci)=Replace(arrstr(intIci),"(","(")
arrstr(intIci)=Replace(arrstr(intIci),")",")")
arrstr(intIci)=Replace(arrstr(intIci),"_","_")
arrstr(intIci)=Replace(arrstr(intIci),"+","+")
arrstr(intIci)=Replace(arrstr(intIci),"|","|")

arrstr(intIci)=Replace(arrstr(intIci),",",",")
arrstr(intIci)=Replace(arrstr(intIci),".",".")
arrstr(intIci)=Replace(arrstr(intIci),"/","/")
arrstr(intIci)=Replace(arrstr(intIci),"'","’")
arrstr(intIci)=Replace(arrstr(intIci),";",";")
arrstr(intIci)=Replace(arrstr(intIci),"<","<")
arrstr(intIci)=Replace(arrstr(intIci),">",">")
arrstr(intIci)=Replace(arrstr(intIci),"?","?")
arrstr(intIci)=Replace(arrstr(intIci),chr(34),"”")
arrstr(intIci)=Replace(arrstr(intIci),":",":")

arrstr(intIci)=Replace(arrstr(intIci)," "," ")

next

if howmany<>"" then
response.Write left(arrstr(0),Cint(howmany))
else
for intIci=0 to UBound(arrstr)
response.Write(arrstr(intIci))&"<br>"
next
end if

end function
%>

----------------------------------------

2:根据字数设置换行:
----------------------------
百度网友22f335701
2006-08-26 · TA获得超过672个赞
知道小有建树答主
回答量:1194
采纳率:0%
帮助的人:986万
展开全部
response.write replace(x,vbcrlf,"<br>")
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
地图世纪网
2006-08-26 · TA获得超过957个赞
知道小有建树答主
回答量:340
采纳率:0%
帮助的人:0
展开全部
x=rs("content")
x=replace(x,chr(13),"<br>")
response.write x
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式