首先在你网站根目录下新建一个名为: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>
六天,看来你够苦的.帮你一下,用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>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)