建站代码网

热门标签

ASP表单输入到HTML

ASP能写.html或者任何其他的直接到web服务器的文档文本(你需要写文本输出到写权限的目录)。这是能够不需要上传PC的文件用户输入即时的发布信息。
下面的例子有四个输入区域(标题{要求的}),字号。段落1和段落2)。从这些输入的值里,一个文本对象会被创建有.html的服务器上(仅仅是和像.asp,.inc,.txt,.html一样容易的)从用户输入的破折号和当前日期的扩展名。其他的出入会被写到文本对象,也能够在相关页面 看到。


<% 检查如果标题能否被输入 u_title=request.form("u_title") if u_title = "" then %> <!-- Input form area - This will only display when no Title has been entered --> <form method="POST" action="<%= request.servervariables("script_name") %>"> <p>document Title<br> <input type="text" name="u_title" size="35"></p> <p>Font Size<br> <select size="1" name="u_text_size"> <option selected value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> &nbsp; </select></p> <p>Paragraph 1<br> <textarea rows="2" name="u_paragraph1" cols="35"></textarea></p> <p>Paragraph 2<br> <textarea rows="2" name="u_paragraph2" cols="35"></textarea><input type="submit" value="Submit" ></p> </form> <% end if %> <% if u_title <> "" then 如果这里有用户输入标题 获取所有用户输入值 u_title=request.form("u_title") u_paragraph1=request.form("u_paragraph1") u_paragraph2=request.form("u_paragraph2") u_text_color=request.form("u_text_color") u_text_size=request.form("u_text_size") g_filename=replace(u_title," ","_") set fso = createobject("scripting.filesystemobject") 创建文本(html)文件到服务器,在g 标题值后面添加-mmddyyyy Set act = fso.CreateTextFile(server.mappath("write2htm/"&g_filename & "-"& month(date())& day(date())& year(date()) &".htm"), true) 写入所有的用户输入到文本(html)文档 .html 扩展名能和.asp或者.inc一样可以满足你的所有需求 act.WriteLine "<html>" act.WriteLine chr(13) act.WriteLine "<title>"& u_title &"</title>" act.WriteLine chr(13) act.WriteLine "<body bgcolor='#FFFFFF'>" act.WriteLine chr(13) act.WriteLine "<p align='center'><font face='arial' size='"& u_text_size &"'>" act.WriteLine chr(13) act.WriteLine u_title &"</p>" act.WriteLine chr(13) act.WriteLine "<p align='left'><font face='arial' size='"&u_text_size&"'>" act.WriteLine chr(13) act.WriteLine u_paragraph1 &"</p>" act.WriteLine chr(13) act.WriteLine "<p align='left'><font face='arial' size='"& u_text_size &"'>" act.WriteLine chr(13) act.WriteLine u_paragraph2 &"</p>" act.WriteLine chr(13) act.WriteLine "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>" act.WriteLine "<p align='center'><font face='arial' size='"& u_text_size &"'>" act.WriteLine "This document was created on&nbsp;" act.WriteLine now() &"</p>" 关闭文档 act.Close %> Your page has been successfully create and can be viewed by clicking <a href="write2htm/<%= g_filename & month(date())& day(date())& year(date()) %>.htm" target="_blank">here</a> <br> <br> <% response.write "<html>" response.write chr(13) response.write "<title>"& u_title &"</title>" response.write chr(13) response.write "<body bgcolor='#FFFFFF'>" response.write chr(13) response.write "<p align='center'><font face='arial' size='"& u_text_size &"'>" response.write chr(13) response.write u_title &"</p>"