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

ASP
asp搜索两个以上的词的原理
如何使用花生壳?
asp汉字转换成汉语拼音代码
asp程序实现伪静态的代码
asp处理xml数据的发送、接收类
ASP中使用jmail发送邮件的函数
asp中获取字符串中的时间字符串
ASP按照字数限制自动截取标题内容
asp中将内容生成word文档的函数
用ASP自动清空IE缓存里的内容
asp检测conn.execute是否执行成功的函数
自动获取当前页面URL的ASP函数
ASP采集中获取网页内所需的html代码
asp图片采集并且本地重命名保存的函数
如何使用asp去字符串中的超链接
asp网站通过限制请求防止被采集的函数
asp利用正则去掉字符串中所有html内容
用ASP取出HTML里面的图片地址的函数
fso实现整个文件夹内容的复制到另一个文件夹中
适合所有表的添加、删除、修改的函数

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 50 ::
收藏到网摘: 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("字段名"))%>