開始將多行區域表單中的內容沒有處理,就直接保存起來,然後在顯示的時候發現,明明保存的時候有換行等格式,但是顯示不出來,所有的內容都在一行上。原因是沒有將多行區域表單中的內容換成Html格式引起這個原因的。
01
02
Function inHtml(str)
03
Dim sTemp
04
sTemp = str
05
inHtml = ""
06
If IsNull(sTemp) = True Then
07
Exit Function
08
End If
09
10
sTemp = Replace(sTemp, "&", "&")
11
sTemp = Replace(sTemp, "<", "<")
12
sTemp = Replace(sTemp, ">", ">")
13
stemp=Replace(stemp, CHR(39), "'")
14
stemp= Replace(stemp, CHR(32), " ")
15
sTemp = Replace(sTemp, Chr(34), """)
16
stemp = Replace(stemp, CHR(13), """")
17
stemp = Replace(stemp, CHR(10), "<br>")
18
inHtml = sTemp
19
End Function
20
21
22
Function outHtml(str)
23
Dim sTemp
24
sTemp = str
25
outHtml = ""
26
If IsNull(sTemp) = True Then
27
Exit Function
28
End If
29
stemp=replace(stemp,"<br>",chr(10))
30
stemp=replace(stemp,"""",chr(13))
31
stemp=replace(stemp,""",chr(34))
32
stemp=replace(stemp," ",chr(32))
33
stemp=replace(stemp,"'",chr(39))
34
stemp=replace(stemp,">",">")
35
stemp=replace(stemp,"<","<")
36
stemp=replace(stemp,"&","&")
37
38
outHtml = sTemp
39
End Function(鼠標移到代碼上去,在代碼的頂部會出現四個圖標,第一個是查看源代碼,第二個是復制代碼,第三個是打印代碼,第四個是幫助)
用法:
text=inhtml(request("textarea"))'這樣就將textarea中的內容轉換成了Html代碼
當顯示數據庫中這個內容到多行表單方法
<textarea name="textarea" cols="30" rows="30"><%=outHtml(rs("字段名"))%>