开始将多行区域表单中的内容没有处理,就直接保存起来,然后在显示的时候发现,明明保存的时候有换行等格式,但是显示不出来,所有的内容都在一行上。原因是没有将多行区域表单中的内容换成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, "&", "&")
sTemp = Replace(sTemp, "<", "<")
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,"<","<")
stemp=replace(stemp,"&","&")
stemp=replace(stemp,"&",chr(38))
outHTML = sTemp
End Function
%>
用法:
text=inhtml(request("textarea"))'这样就将textarea中的内容转换成了html代码
当显示数据库中这个内容到多行表单方法
<textarea name="textarea" cols="30" rows="30"><%=outhtml(rs("字段名"))%>