📄 tp_do.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#include file="cls_DB.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
'判断该项目是否已投票
Tid=request("Tid")
if request.Cookies("isvoted")("voteid"&Tid)=Tid then
response.write "<script>alert('对不起,'"_
&"+'这个主题您已经投过票了!');history.back();</script>"
response.end
end if
if request("XuanZe")="radio" then '单选形式处理
if request("option")="" then '必须要选择一个选项
response.write "<script>alert('请选择投票选项!');"_
&"+history.back();</script>"
response.end
else
openDB
'options表中选中的votes值和titles表中的Counts值均加1
conn.Execute("Update options SET votes = "_
&"votes+1 Where Oid = " &request("option"))
conn.Execute("Update titles SET Counts = Counts+1 "_
&"Where id = " &Tid)
closeDB
end if
elseif request("XuanZe")="checkbox" then '多选形式处理
if request("option")="" then
response.write "<script>alert('请选择投票选项!');"_
&"+history.back();</script>"
response.end
else
openDB
'request("option").count指:选中的选项总数
for i=1 to request("option").count
'读取每个选中的选项,并使votes值都加1
conn.Execute("Update options SET votes = votes+1 "_
&"Where Oid = " &request("option")(i))
next
'titles表中的Counts值就是被选中的选项总数
conn.Execute("Update titles SET Counts = Counts+"&_
request("option").count&" Where id = " &Tid)
closeDB
end if
end if
'写入Cookies,变量名称加入Tid的值
response.Cookies("isvoted")("voteid"&Tid)=Tid
response.Cookies("isvoted").expires=dateAdd("yyyy",1,now)
'投票主题id,转到投票结果显示页面查看该项目的投票结果
response.Redirect "counteshow.asp?tid="&Tid
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -