注册 登录
编程论坛 ASP技术论坛

一个投票系统怎么才能设计好多选为只能选择3个投票

jackixu 发布于 2010-07-09 15:23, 791 次点击
一个投票系统怎么才能设计好多选为只能选择3个投票?
高手帮我看以下。谢谢。
只有本站会员才能查看附件,请 登录
9 回复
#2
jackixu2010-07-09 15:24
自己顶一下。。急啊。不懂得怎么设置.请会的朋友帮我改以下,发到我的邮箱jackxutz@谢谢!
#3
yms1232010-07-09 15:33
用复选框的话,循环统计选中复选框的数量,超过3个就提示出来。
#4
jackixu2010-07-09 15:50
怎么在哪个地方那个改呢?可以指点一下吗?
#5
jackixu2010-07-09 16:11
大家下载一下那个投票系统帮我看看 ,指点一下。谢谢!
#6
jackixu2010-07-10 09:22
<!--#include file="const.asp"-->
<!--#include file="conn.asp"-->
<%'on error resume next

if isnull(request.cookies("cardnumber")) or request.cookies("cardnumber")=empty then
response.cookies("cardnumber")="|"
response.cookies("cardnumber").Expires=Date+365
end if

set rs=server.createobject("adodb.recordset")

'*********************************判断投票项目是否已经关闭
sql="select kg,overtime from class where id="&request("classid")
rs.open sql,conn,3,1
if rs("kg")=1 then
response.write "<script>alert('这次活动已经结束。');</script>"
rs.close
call show()
end if

'*****************************************判断投票项目是否已经过期
if left(rs("overtime"),2)<>"0-"then
if datediff("s",now,formatdatetime(rs("overtime")))<0 then
response.write "<script>alert('这次投票活动已经截止。');</script>"
rs.close
call show()
end if
end if
rs.close

'****************************************判断是否已经投票过了
if instr(request.cookies("cardnumber"),"|"&request("classid")&"|")<>0 then
response.write "<script>alert('您已经投过票了,请勿重复投票,谢谢!。');</script>"
call show()
response.end
end if

'*********************************************进行数据库操作
if request("style")="radio" then
if isnull(request("voted")) or request("voted")=empty then
response.write "<script>alert('请选择投票主题。');window.close()</script>"
call rsclose
call connclose
response.end
end if
sql="select * from vote where id="&request("voted")
rs.open sql,conn,3,2
rs("count")=rs("count")+1
rs.update
rs.close
elseif request("style")="checkbox" then
if request("voted").count=0 then
response.write "<script>alert('请选择投票主题。');window.close()</script>"
call rsclose
call connclose
response.end
end if
for i=1 to request("voted").count
sql="select * from vote where id="&request("voted")(i)
rs.open sql,conn,3,2
rs("count")=rs("count")+1
rs.update
rs.close
next
end if
response.cookies("cardnumber")=request.cookies("cardnumber")&request("classid")&"|"
response.cookies("cardnumber").Expires=Date+365
'*************************************显示投票结果
call show()

function show
response.write "<script>location.href='showvote.asp?classid="&request("classid")&"';</script>"
call rsclose()
call connclose()
response.end
end function
'Response.Write Err.description%>
#7
jackixu2010-07-10 09:24
以上怎么修改才能是只能投三个票?或者一个IP一天能投三个票?
#8
yms1232010-07-10 16:48
if request("voted").count=0 then
response.write "<script>alert('请选择投票主题。');window.close()</script>"
call rsclose
call connclose
response.end
end if
关键是这句话,多选最多只能投3个票可以加判断比如这句话后面加
if request("voted").count>3 then
response.write "<script>alert('最多只能投3个票。');window.close()</script>"
call rsclose
call connclose
response.end
end if
加IP限制就必须要增加数据表了
#9
jackixu2010-07-10 20:10
谢谢了!非常谢谢!解决这个问题了.
#10
只是爱2012-11-16 14:36
学习了
1