survey.asp
<%@ language="VBScript" %>
<%
if not isempty(Request.Form("voterID")) then
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "sodanoorg00_vote04"
set codes = conn.Execute("select StudentID from ELStudents")
dim passw
dim flag
dim insertCommand
insertCommand = false
passw = Request.Form("voterID")
flag = 0
Do Until codes.EOF
if codes("StudentID") = passw then
flag = 1
end if
codes.MoveNext
Loop
if flag = 0 then
Response.Redirect "signin.asp"
end if
else
if not isempty(Request.Form("7")) then
if insertCommand = true then
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "sodanoorg00_vote04"
conn.Execute "insert into YearResponse (PresidentID,GradeResponse) values ('" & Request.Form("7") & "','" & Request.Form("3") & "')"
conn.Execute "insert into HoodResponse (PresidentID,HomeSchoolResponse) values ('" & Request.Form("7") & "','" & Request.Form("5") & "')"
conn.Execute "insert into SexResponse (PresidentID,GenderResponse) values ('" & Request.Form("7") & "','" & Request.Form("6") & "')"
conn.Execute "insert into PresidentResponse (PresidentID) values ('" & Request.Form("7") & "')"
end if
Response.Redirect "exit.html"
else
Response.Redirect "signin.asp"
end if
end if
%>
<%
set Quets = conn.Execute("select QuestionID, QuestionText from ELQuestions")
%>
<html>
<head>
<LINK REL=stylesheet HREF="style.css" TYPE="text/css">
<style type="text/css">
div#s_i_box{ border-left:2px solid red; border-top:2px solid red; border-bottom:2px solid blue; border-right:2px solid blue;
background:#FFFFFF; width:420px; top:190px; text-align:left; padding:10px; }
</style>
<script language="JavaScript" type="text/javascript">
var submitCommand = true;
function review(grade,hs,gen,vote){
for(i=0;i<4;i++){
if(document.the_form[i].value=="blank"){
alert("Question " + (i+1) + " is unanswered.");
return false;
}
}
var info = "Click ok to confirm and cast your ballot,\nClick cancel to make changes.\n\n";
info += "Grade: " + grade + "\n";
info += "Home School: " + hs + "\n";
info += "Gender: " + gen + "\n";
info += "Your Vote: " + vote + "\n";
if(confirm(info)){
document.getElementById("subby").style.visibility = "hidden";
alert("The polls are closed.");
if(submitCommand==true)
document.the_form.submit();
return true;
}
else{
return false;
}
}
</script>
<title>DeKalb School of The Arts Election 2004</title>
</head>
<body>
<center><img src="titleimg.jpg"></center>
<br/>
<div id="s_i_box">
<form name="the_form" action="survey.asp" method="post">
<center><b>Ballot</b></center><br />
<br />
<%
dim q
q = 1
Do Until Quets.EOF
%>
<% response.write (q&". "&Quets("QuestionText")) %>
<select name="<% response.write Quets("QuestionID") %>">
<option value="blank">choose one</option>
<%
set Answs = conn.Execute("select AnswerID, AnswerText from ELAnswers where QuestionID = "&Quets("QuestionID"))
Do Until Answs.EOF
%>
<option name="<% response.write Answs("AnswerID") %>" value="<% response.write Answs("AnswerText") %>">
<% response.write Answs("AnswerText") %>
</option>
<%
Answs.MoveNext
Loop
%>
</select><br /><br />
<%
q = q+1
Quets.MoveNext
Loop
%>
<%
Quets.Close
Answs.Close
conn.Close
%>
<br />
<center><input type="button" name="Submit" id="subby" value="Place your Vote" onClick="review(document.the_form[0].value,document.the_form[1].value,document.the_form[2].value,document.the_form[3].value)"></center>
</form>
</div>
</body>
</html>