asp代码,点击按钮一写入“1”倒记事本点击按钮2覆盖写入“2”到记事本
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
<%
num=Request.QueryString("num")
if num<>"" then
fileName=Server.MapPath("num.txt")
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists(fileName) Then
fs.CreateTextFile fileName,True,True
Set txt=fs.OpenTextFile(fileName,2,True)
txt.Write 1
else
Set txt=fs.OpenTextFile(fileName,2,True)
txt.Write num
End If
txt.close()
Set txt=Nothing
set fs=nothing
end if
%>
<form method="POST" action="index.asp?num=1">
<input type="submit" value="按钮1">
</form>
<form method="POST" action="index.asp?num=2">
<input type="submit" value="按钮2">
</form>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set txt=fs.OpenTextFile(fileName,1,True)
response.write "TXT文件内容是:"&txt.readall
txt.close
Set txt=Nothing
set fs=nothing
%>
效果图: