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

ASP
ASP实例代码:搞个长文章分页代码
说说对象的复制
多个函数验证同一表单
查询某个字段没有值的所有记录的SQL语句怎么写?
ASP实例:一个简单的ASP无组件上传类
ASP实例讲解:用分页符实现长文章分页显示
ASP实例:动态网页中常用的6个ASP程序
ASP实例:词语搭配游戏的制作
ASP实例学习:随机生成文件名的函数
asp实例:测试WEB服务器
ASP实例:计数器程序详解
预防ASP网站被黑 彻底了解ASP木马
分享:XML HTTP Request的属性和方法简介
ASP架设:给每个IIS站点建立一个用户
ASP技巧:判断远程图片是否存在
故障解决:解决ASP脚本运行超时的方法
再说ASP输出N行N列表格
怎么判断一个对象是否已被释放
ASP实现网页打开任何类型文件都保存的方法
ASP技巧:利用函数InstrRev()获取当前文件名

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


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