投票的例子
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
	div{float:left;width:400px;margin-left:50px;}
	img{width:200px;height:300px;}
</style>
<% 
	'读取文件的投票数函数
	function counter_read(counterfile)
		dim fso,ts,counter
			set fso=server.createobject("scripting.filesystemobject")
			set ts=fso.opentextfile(server.mappath(counterfile),1,true)'先要打开才能进行读取,已只读的形式,没有则建立
			if not ts.atendofstream then
			   counter=ts.readline
			 else
			 	counter=1
			end if
			ts.close
			set ts=nothing
			set fso=nothing
		counter_read=counter
	end function
	dim counter_jet,counter_cheng,counter_zhou
	counter_jet=counter_read("jetlee.txt")
	counter_cheng=counter_read("cheng.txt")
	counter_zhou=counter_read("zhou.txt")
		'写入票数的函数
	sub counter_write(counterfile)
		dim fso,ts,counter
		application.lock
			set fso=server.createobject("scripting.filesystemobject")
			set ts=fso.opentextfile(server.mappath(counterfile),2,true)
			counter=counter_read(counterfile)+1
			ts.writeline(counter)
			ts.close
			set ts=nothing
			set fso=nothing
		application.unlock
	end sub
	
	'对点击的图片进行判段
	select case request.querystring("name")
		case "jetlee"
			call counter_write("jetlee.txt")'写入文件的函数要有1.文件名称2,投票数
		case "cheng"
			call counter_write("cheng.txt")
		case "zhou"
			call counter_write("zhou.txt")
	end select
%>
</head>
<body>
	
	<div>
		<dl>
			<dt><a href="gx_9.asp?name=jetlee"><img src="jetlee.gif"></a></dt>
			<dd>李连杰<%=counter_read("jetlee.txt")%>票</dd>	
		</dl>	
	</div>
	
	<div>
		<dl>
			<dt><a href="gx_9.asp?name=cheng"><img src="cheng.gif"></a></dt>
			<dd>成龙<%=counter_read("cheng.txt")%>票</dd>	
		</dl>	
	</div>
	
	<div>
		<dl>
			<dt><a href="gx_9.asp?name=zhou"><img src="zhou.gif"></a></dt>
			<dd>周星驰<%=counter_read("zhou.txt")%>票</dd>	
		</dl>	
	</div>
</body>
</html>
这是一个简单的图片投票例子,使用超链接做成的
请问我为什么在写入函数里面调用读取函数不行呢,?在网页的结果就是每张图片的票数最多为2,以后不管怎么点击都没用
              
------解决方案--------------------set ts=fso.opentextfile(server.mappath(counterfile),2,
true)
counter=counter_read(counterfile)+1
设置为true后就重新创建了文件,这样第二句永远为2,调换下循序