当前位置: 首页 > 图文教程 > 网络编程 > ASP > 将多行区域表单中的内容换成html代码

ASP
对ASP和ASP程序员的一些话
10行代码让你告别Arp作恶导致的掉线
ASP开发10条经验总结
国内ASP应用,不容乐观
ASP利用Google实现在线翻译功能
如何提高自己的编程水平
经典实用的基础asp程序整理
ASP实现带进度条的测试网速的代码程序
ASP程序实现网页伪静态页源代码
净化网络环境 ASP程序实现过滤脏话
ASP技术与PHP,CGI,JSP等技术的比较
用ASP制作饼图、柱状图等
常用ASP脚本程序集锦
用ASP编写的俄罗斯方块游戏
几种优秀的开发ASP的工具
浅谈ASP编程的思路与纠错
一个测试数据库连接的函数
ASP读写注册表
怎样用ASP程序判断一个盘上是否有文件
一个免费的简单聊天室源代码

ASP 中的 将多行区域表单中的内容换成html代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 54 ::
收藏到网摘: n/a

开始将多行区域表单中的内容没有处理,就直接保存起来,然后在显示的时候发现,明明保存的时候有换行等格式,但是显示不出来,所有的内容都在一行上。原因是没有将多行区域表单中的内容换成html格式引起这个原因的。
<%
Function inHTML(str) '将表单中的内容换成html格式,用于将表单中内容写入数据库
Dim sTemp
sTemp = str
inHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
stemp=Replace(stemp, CHR(38), "&")
sTemp = Replace(sTemp, "&", "&amp;")
sTemp = Replace(sTemp, "<", "&lt;")
sTemp = Replace(sTemp, ">", ">")
stemp=Replace(stemp, CHR(39), "'")
stemp= Replace(stemp, CHR(32), " ")
sTemp = Replace(sTemp, Chr(34), """)
stemp = Replace(stemp, CHR(13), "")
    stemp = Replace(stemp, CHR(10), "
")
inHTML = sTemp
End Function

Function outHTML(str) '将html格式显示出多行区域表单中,用于修改表单中的内容。
Dim sTemp
sTemp = str
outHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If  
stemp=replace(stemp,"
",chr(10))
stemp=replace(stemp,"",chr(13))
stemp=replace(stemp,""",chr(34))
stemp=replace(stemp," ",chr(32))
stemp=replace(stemp,"'",chr(39))
stemp=replace(stemp,">",">")
stemp=replace(stemp,"&lt;","<")
stemp=replace(stemp,"&amp;","&")
stemp=replace(stemp,"&",chr(38))
outHTML = sTemp
End Function
%>
用法:
 text=inhtml(request("textarea"))'这样就将textarea中的内容转换成了html代码
 当显示数据库中这个内容到多行表单方法
 <textarea name="textarea" cols="30" rows="30"><%=outhtml(rs("字段名"))%>