To generate an instance code of an HTML file using ASP

Source: Internet
Author: User
Tags date end html input text reset
Generate HTML Total two pages index.htm is the first page. The program is simple, mainly using the ASP file Operation object.
<!--index.htm------------------------------------------------------------------------------->

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"http://www.w3.org/TR/html4/loose.dtd" >
<title>untitled document</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

<body>
<table width= "770" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<td><form name= "Form1" method= "Post" action= "send.asp" >
<table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" bgcolor= "#CCFFFF" >
<tr>
&LT;TD height= ><div align= "center" > Send Message </div></td>
</tr>
<tr>
<td><div align= "center" >
<textarea name= "msg" cols= "rows=" 6 "></textarea>
</div></td>
</tr>
<tr>
<td><div align= "center" >
<input type= "Submit" name= "submit" value= "Submit" >
<input type= "reset" name= "Submit2" value= "reset" >
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
'//send.asp

<%
function Chan_time (Shijian) ' Convert date-time function
S_year=year (Shijian)
If Len (s_year) =2 then s_year= "&s_year"
S_month=month (Shijian)
If S_month<10 then s_month= "0" &s_month
S_day=day (Shijian)
If S_day<10 then s_day= "0" &s_day
S_hour=hour (Shijian)
If S_hour<10 then s_hour= "0" &s_hour
S_minute=minute (Shijian)
If S_minute<10 then s_minute= "0" &s_minute
Chan_time=s_year & S_month & s_day & S_hour & S_minute
End Function

function Chan_data (Shijian) ' Convert date-time function
S_year=year (Shijian)
If Len (s_year) =2 then s_year= "&s_year"
S_month=month (Shijian)
If S_month<10 then s_month= "0" &s_month
S_day=day (Shijian)
If S_day<10 then s_day= "0" &s_day
Chan_data=s_year & S_month & S_day
End Function

function Chan_file (Shijian) ' Convert date-time function
S_month=month (Shijian)
If S_month<10 then s_month= "0" &s_month
S_day=day (Shijian)
If S_day<10 then s_day= "0" &s_day
S_hour=hour (Shijian)
If S_hour<10 then s_hour= "0" &s_hour
S_minute=minute (Shijian)
If S_minute<10 then s_minute= "0" &s_minute
S_ss=second (Shijian)
If S_ss<10 then s_ss= "0" &s_ss
Chan_file = s_month & S_day & S_hour & S_minute & S_SS
End Function
top= "Botom= "</body>Msg=request. Form ("MSG")
Msg=replace (Msg,vbcrlf, "")
Msg=replace (MSG,CHR (9), "")
Msg=replace (MSG, "", "")
Msg=replace (msg, "\ r \ n", "<br>")
Msg=replace (msg, "\ n", "<br>")
Msg=top&msg&botom
Set fs=server.createobject ("Scripting.FileSystemObject")
All_tree2=server.mappath ("News") & "\" &chan_data (now)
if (fs. FolderExists (all_tree2)) Then ' Judge if today's folder exists
Else
Fs. CreateFolder (ALL_TREE2)
End If
Pass=chan_file (now)
Randomize ' uses the system timer to initialize the number of Chaos generator
Pass=rnd (pass)
Pass=get_pass (pass)
Pass=left (pass,10)


File1=pass
files=file1& ". txt"
filez=all_tree2& "\" &files


Set ts = fs.createtextfile (filez,true) ' Write file
For Z=1 to Len (msg)
Write_now=mid (msg,z,1)
Ts.write (Write_now)
Next
' Ts.writeline (all_msg)
Ts.close
Set ts=nothing ' File generation

 if err.number<>0 or err Then%>
  <script language= "javascript"
   alert ("Cannot complete")
  </SCRIPT>
 <%else%>
  <script language= "JavaScript"
 alert ( Completed)
 history.back ();
  </SCRIPT>
 <%end if
 set MyFile = fs. GetFile (Filez)
 all_tree2=server.mappath ("News") & "\" &chan_data (now)
 if (fs. FolderExists (all_tree2)) then
 else
 fs. CreateFolder (all_tree2)
 end if
 myfile.name= left (Myfile.name,len (myFile.Name)-4) & ". htm"
 set myfile=nothing
 set fs=nothing
 set fdir=nothing
Function Get_pass (pass)

Pass=cstr (pass)
Pass=replace (Pass, "", "")
Pass=replace (Pass, "", "")
Pass=replace (Pass, "-", "")
Pass=replace (Pass, "", "")
Pass=replace (Pass, ":", "")
Pass=replace (Pass, ".", "")
Pass=replace (pass, "+", "")
Pass=replace (Pass, "_", "")
Pass=replace (Pass, "<", "")
Pass=replace (pass, ">", "")
Pass=replace (pass, "!", "")
Pass=replace (pass, "@", "")
Pass=replace (Pass, "#", "")
Pass=replace (pass, "$", "")
Pass=replace (pass, "%", "")
Pass=replace (pass, "^", "")
Pass=replace (Pass, "&", "")
Pass=replace (Pass, "*", "")
Pass=replace (Pass, "(", "")
Pass=replace (pass, ")", "" "
Pass=replace (pass, "=", "")
Pass=replace (pass, "\", "")
Pass=replace (Pass, "/", "")
Pass=replace (pass, "|", "")
Get_pass=pass

End Function

%>


'//

Put send.asp and index.htm in your ASP directory, and then build a news folder. Open the browser, enter in the Address bar: http://your machine name/your ASP virtual directory name/index.html input text, then submit, ok! See if you have a new folder in the new News folder in your ASP directory, and it's named after the current date. It has the text you just submitted to see if the HTML file was generated. How, you can do a simple press release system on this basis.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.