開始將多行區域表單中的內容沒有處理,就直接保存起來,然后在顯示的時候發現,明明保存的時候有換行等格式,但是顯示不出來,所有的內容都在一行上。原因是沒有將多行區域表單中的內容換成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("字段名"))%>