3.3.4界面设计与重点、难点代码设计
投票页面
该页面是一个纯HTML文件,它让用户选择自己想选举的候选人,并填写自己的详细资料,以确认投票的有效性。页面显示如图所示。
表单处理脚本
在vote.htm中各项数据都填写完毕后,单击确定投票按钮,表单的数据就被提交,
本次评优共有4个候选人,但只能选两个。故用复选框。
投票的有效性通过是否是本校学生,且是否投过票来判断。
if request("passno")<>"" then
sql="select * from stud where password="&"'"&request("passno")&"'" &"and yitu=0"
set rs=cn.execute(sql)
if rs.eof then%>
<h2 align=center><%response.write"你无权投票"%></h2>
本设计允许少选,不允许多选。通过判断Vote投票界面传递过来的复选按纽值的长度看是否多选。
vo=request("cand")
if len(vo)>4 then%>
<h2 align=center><%response.write "多选了,无效"%></h2>
然后根据所投的票将对应候选人的投票结果字段加1,同时将该投票人的已投字段置为1。
sqq="update stud set yitu=1 where password="&"'"&request("passno")&"'"
cn.execute(sqq)
if instr(vo,"1") then
cn.execute("update stud set result=result+1 where name='李宁'")
end if
if instr(vo,"2") then
cn.execute("update stud set result=result+1 where name='杨兰'")
end if
if instr(vo,"3") then
cn.execute("update stud set result=result+1 where name='江道明'")
end if
if instr(vo,"4") then
|