1, practice using the Request object to accept the data and use a combination of functions.
Cnbruce.html
<form action= "cnbruce.asp" method= "POST" >
<input type= "text" name= "title" ><br>
<textarea name= "Content" rows=10 cols=20></textarea><br>
<input type= "Submit" >
</form>
|
Cnbruce.asp
<%
function th (str)
Str=replace (str, "damn", "MD")
Str=replace (str, "lean", "KAO")
Th=str
End Function
function encode (str)
str = replace (str, ">", ">")
str = replace (str, "<", "<")
str = Replace (str, CHR (32), "")
str = Replace (str, CHR (13), "")
str = Replace (str, CHR (a) & CHR (a), "</P><P>")
str = Replace (str, CHR (Ten), "<BR>")
Encode=str
End Function
%>
<%title=request.form ("title")
Content=request.form ("content")%>
Article title: <%=th (title)%>
Article content: <%=encode (content)%>
|
Th (str) is a custom function, the main function is simple: filter characters. Encode (str) is also a custom function, and the primary function is to fully display the information that is being passed.
CHR (10) means a newline, CHR (13) is a carriage return, and CHR (32) denotes a space.
Additional functionality: Displays UBB code.
That is, the ubb.asp contains the UBB () function.
Enhanced cnbruce.asp
<!--#include file= "http://www.cnbruce.com/blog/ubb.asp"-->
<%
function th (str)
Str=replace (str, "damn", "MD")
Str=replace (str, "lean", "KAO")
Th=str
End Function
%>
<script>
function RunEx (COD1) {
Cod=document.all (COD1)
var Code=cod.value;
if (code!= "") {
var newwin=window.open (', ', ', ');
Newwin.opener = null
Newwin.document.write (code);
Newwin.document.close ();
}
}
</script>
<%title=request.form ("title")
Content=request.form ("content")%>
Article title: <%=th (title)%>
Article: <%=ubb (unhtml (content))%>
|