function setCookie(cookieName, cookieValue) {
if(cookieValue == "") {
return
}
var date = new Date()
date.setTime(date.getTime()+1000*(60*60*24*10)) //设置cookie过期时间
document.cookie = cookieName + "=" + escape(cookieValue) + "expires=" + date.toGMTString()
}/*根据cookie名称读取cookie的值@param cookieName -- Cookie名称*/function readCookieValue(cookieName) {
var v = document.cookie
var start1 = v.indexOf(cookieName)
if(start1 == -1) { //没有找到对应名称的Cookie
return ""
}else {
var start = v.indexOf("=",start1)+1
var end = v.indexOf("",start)
return unescape(v.substring(start,end))
}
}
六天,看来你够苦的.帮你一下,用application做的,不知你是否满意,首先在你网站根目录下新建一个名为:Global.asa的文件,然后把下列代码贴上去:
<script language="vbscript" runat="server">
Sub Application_OnStart
application("yes")=0
application("no")=0
End Sub
</script>
然后再建一个投票的ASP文件,内容:
<style type="text/css">
<!--
.Vote {
height: 15px
width: 200px
border: 1px solid #0033FF
}
#cYes {
background-color: #FF6600
height: 15px
width: 100px
}
#cNo {
background-color: #FF6600
height: 15px
width: 100px
}
-->
</style>
<form action="" method="post">
做一个投票系统难吗?<br />
<input name="yes" type="radio" value="yes" onclick="if (this.checked==true) no.checked=false" />赞成<br />
<input name="no" type="radio" value="no" onclick="if (this.checked==true) yes.checked=false"/>反对<br />
<input name="投票" type="submit" value="投票" />
</form>
<%
nyes=0
nNo=0
'如果想重新计票,用下面四行
'application.lock()
'application("yes")=application("yes")+1
'application("no")=application("no")+1
'application.unlock()
count=application("yes")+application("no")
if count<>0 then
nyes=int(application("yes")*200/count)
nNo=int(application("no")*200/count)
end if
sYes=Request.form("yes")
sNo=Request.form("no")
act= Request.form("投票")
if act="投票" Then
if sYes="yes" Then
application.lock()
application("yes")=application("yes")+1
application.unlock()
Else
if sNo="no" then
application.lock()
application("no")=application("no")+1
application.unlock()
end if
End if
'图形化显示投票结果
count=application("yes")+application("no")
if count<>0 then
nyes=int(application("yes")*200/count)
nNo=int(application("no")*200/count)
end if
end if
%>
赞成:<%=application("yes")%>票
<div class="Vote" ><div ID="cYes" neme="cYes" style="width:<%=nyes%>px"></div></div>
反对::<%=application("no")%>票
<div class="Vote" ><div ID="cNo" neme="cNo" style="width:<%=nNo%>px"></div></div>