ASP文本计数器的问题?
代码如下:请问为什么我刷新后就不再显示基数了呢?我希望刷新后仍能看到计数结果,只是数值没增加罢了。<%ifsession("iscount")=""thensession...
代码如下:请问为什么我刷新后就不再显示基数了呢?我希望刷新后仍能看到计数结果,只是数值没增加罢了。
<%
if session("iscount")="" then
session("iscount")="iscount"
dim count
Set fs=CreateObject("scripting.filesystemobject")
Set hs=fs.opentextfile(server.Mappath("count.txt"))
count=hs.readline
count=count+1
response.write "您是第" & count & "位访问者!"
Set hs=fs.createtextfile(server.Mappath("count.txt"))
hs.writeline(count)
hs.close
set fs=nothing
end if
%>
我试过了,但还是不行。刷新后不显示任何文字,就连“您是第...位访问者”都显示不出来。很郁闷。 展开
<%
if session("iscount")="" then
session("iscount")="iscount"
dim count
Set fs=CreateObject("scripting.filesystemobject")
Set hs=fs.opentextfile(server.Mappath("count.txt"))
count=hs.readline
count=count+1
response.write "您是第" & count & "位访问者!"
Set hs=fs.createtextfile(server.Mappath("count.txt"))
hs.writeline(count)
hs.close
set fs=nothing
end if
%>
我试过了,但还是不行。刷新后不显示任何文字,就连“您是第...位访问者”都显示不出来。很郁闷。 展开
1个回答
展开全部
你把判断放在最外层了,当然,刷新后就不执行你后面的显示语句了,改成:
<%
dim count
Set fs=CreateObject("scripting.filesystemobject")
Set hs=fs.opentextfile(server.Mappath("count.txt"))
count=hs.readline
if session("iscount")="" then
session("iscount")="iscount"
count=count+1
end if
response.write "您是第" & count & "位访问者!"
Set hs=fs.createtextfile(server.Mappath("count.txt"))
hs.writeline(count)
hs.close
set fs=nothing
%>
<%
dim count
Set fs=CreateObject("scripting.filesystemobject")
Set hs=fs.opentextfile(server.Mappath("count.txt"))
count=hs.readline
if session("iscount")="" then
session("iscount")="iscount"
count=count+1
end if
response.write "您是第" & count & "位访问者!"
Set hs=fs.createtextfile(server.Mappath("count.txt"))
hs.writeline(count)
hs.close
set fs=nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询