1. exercise using the request object to receive data and use some functions in a comprehensive manner.
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, "Mom", "MD ") Str = replace (str, "by", "KAO ") Th = str End functionFunction encode (str) Str = replace (str, ">", "> ") Str = replace (str, "<", "<") Str = Replace (str, CHR (32 ),"") Str = Replace (str, CHR (13 ),"") Str = Replace (str, CHR (10) & CHR (10), "</P> <P> ") Str = Replace (str, CHR (10), "<BR> ") Encode = str End function %> <% Title = request. form ("title ") Content = request. form ("content") %> Article title: <% = th (title) %> Article content: <% = encode (th (content) %> |
Th (str) is a user-defined function. Its main function is simple: Filter characters. Encode (str) is also a user-defined function. The main function is to completely display the passed information.
CHR (10) indicates line feed, CHR (13) indicates carriage return, and CHR (32) indicates space.
Additional function: displays the UBB code.
Ubb. asp contains the ubb () function.
Enhanced cnbruce. asp
<! -- # Include file = "http://www.cnbruce.com/blog/ubb.asp" --> <% Function th (str) Str = replace (str, "Mom", "MD ") Str = replace (str, "by", "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.doc ument. write (code ); Newwin.doc ument. close (); } } </Script> <% Title = request. form ("title ") Content = request. form ("content") %> Article title: <% = th (title) %> Article content: <% = ubb (unhtml (th (content) %> |