%
'In Config...Dim SurveyId
SurveyId = Request("SurveyId")
Dim Mode
Mode = Request("Mode")
Dim Surveys
If Mode = "Preview" Then
SQL = "SELECT * FROM Survey WHERE SurveyId = " & SurveyId & ";"
Else
SQL = "SELECT * FROM Survey WHERE SurveyId = " & SurveyId & " AND [Active] = True;"
End If
Set Surveys = Server.CreateObject("ADODB.Recordset")
Surveys.CursorType = 1
Surveys.Open SQL, Conn
Dim Questions
SQL = "SELECT * FROM Question WHERE SurveyId = " & SurveyId & " ORDER BY Sequence ASC;"
Set Questions = Server.CreateObject("ADODB.Recordset")
Questions.CursorType = 1
Questions.Open SQL, Conn
Dim Answers
SQL = "SELECT * FROM Answer ORDER BY Sequence ASC;"
Set Answers = Server.CreateObject("ADODB.Recordset")
Answers.CursorType = 1
Answers.Open SQL, Conn
Dim Sessions
SQL = "SELECT * FROM [Session] WHERE SurveyId = " & SurveyId & " AND IPAddress = '" & Request("REMOTE_ADDR") & "';"
Set Sessions = Server.CreateObject("ADODB.Recordset")
Sessions.CursorType = 1
Sessions.Open SQL, Conn
Dim Options
SQL = "SELECT * FROM [Option] ORDER BY OptionGroup ASC, OptionName ASC;"
Set Options = Server.CreateObject("ADODB.Recordset")
Options.CursorType = 1
Options.Open SQL, Conn
%>
<%
Options.Filter = ""
%>
<%
If Surveys.RecordCount <> 0 Then
Response.write Surveys("Name")
Else
%>Survey is currently unavailable<%
End If
%>
<%
'Create the Javascript form validation code.
'Dim QuestionsNumList, QuestionsArray, AnswersValues
Dim JSValCode
Questions.Filter = "Required = True"
If Questions.RecordCount <> 0 Then
Questions.MoveFirst
Do While Not Questions.EOF
'### RADIO BUTTON ###
If Questions("TypeId") = 1 Then
JSValCode = JSValCode & " tmp = getRadioValue(surveyFrm.q" & Questions("QuestionId") & "," & Questions("Sequence") & ");" & vbCrLf
JSValCode = JSValCode & " if (tmp == null)" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " alert('Please select an option for Question " & Questions("Sequence") & ".');" & vbCrLf
JSValCode = JSValCode & " location.href = 'http://" & Request("SERVER_NAME") & Request("URL") & "?" & Request("QUERY_STRING") & "#Question" & Questions("Sequence") & "';" & vbCrLf
If optSimpleJS = False Then
JSValCode = JSValCode & " var PrevClass = a" & Questions("QuestionId") & "tbl.className;" & vbCrLf
JSValCode = JSValCode & " if (PrevClass == '')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " PrevClass = 'NoFlashBG';" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " a" & Questions("QuestionId") & "tbl.className = 'FlashBG';" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",500);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='FlashBG'"",1000);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",1500);" & vbCrLf
End If ' optSimpleJS = False
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " if (tmp == 'Cancel')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " tmp = '';" & vbCrLf
'### CHECKBOX ###
ElseIf Questions("TypeId") = 2 Then
JSValCode = JSValCode & " tmp = getCheckValue(surveyFrm.q" & Questions("QuestionId") & "," & Questions("Sequence") & ");" & vbCrLf
JSValCode = JSValCode & " if (tmp == null)" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " alert('Please select at least one option for Question " & Questions("Sequence") & ".');" & vbCrLf
JSValCode = JSValCode & " location.href = 'http://" & Request("SERVER_NAME") & Request("URL") & "?" & Request("QUERY_STRING") & "#Question" & Questions("Sequence") & "';" & vbCrLf
If optSimpleJS = False Then
JSValCode = JSValCode & " var PrevClass = a" & Questions("QuestionId") & "tbl.className;" & vbCrLf
JSValCode = JSValCode & " if (PrevClass == '')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " PrevClass = 'NoFlashBG';" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " a" & Questions("QuestionId") & "tbl.className = 'FlashBG';" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",500);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='FlashBG'"",1000);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",1500);" & vbCrLf
End If ' optSimpleJS = False
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " if (tmp == 'Cancel')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " tmp = '';" & vbCrLf
'### DROP-DOWN ###
ElseIf Questions("TypeId") = 3 Then
JSValCode = JSValCode & " tmp = getDropDownValue(surveyFrm.q" & Questions("QuestionId") & "," & Questions("Sequence") & ");" & vbCrLf
JSValCode = JSValCode & " if (tmp == null)" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " alert('Please select an option for Question " & Questions("Sequence") & ".');" & vbCrLf
JSValCode = JSValCode & " location.href = 'http://" & Request("SERVER_NAME") & Request("URL") & "?" & Request("QUERY_STRING") & "#Question" & Questions("Sequence") & "';" & vbCrLf
If optSimpleJS = False Then
JSValCode = JSValCode & " var PrevClass = a" & Questions("QuestionId") & "tbl.className;" & vbCrLf
JSValCode = JSValCode & " if (PrevClass == '')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " PrevClass = 'NoFlashBG';" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " a" & Questions("QuestionId") & "tbl.className = 'FlashBG';" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",500);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='FlashBG'"",1000);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",1500);" & vbCrLf
End If ' optSimpleJS = False
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " if (tmp == 'Cancel')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " tmp = '';" & vbCrLf
'### TEXT BOX ###
ElseIf Questions("TypeId") = 4 Then
JSValCode = JSValCode & " tmp = getTextValue(surveyFrm.q" & Questions("QuestionId") & "," & Questions("Sequence") & ");" & vbCrLf
JSValCode = JSValCode & " if (tmp == null)" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " alert('Please enter your Answer for Question " & Questions("Sequence") & ".');" & vbCrLf
JSValCode = JSValCode & " location.href = 'http://" & Request("SERVER_NAME") & Request("URL") & "?" & Request("QUERY_STRING") & "#Question" & Questions("Sequence") & "';" & vbCrLf
JSValCode = JSValCode & " surveyFrm.q" & Questions("QuestionId") & ".focus();"
If optSimpleJS = False Then
JSValCode = JSValCode & " var PrevClass = a" & Questions("QuestionId") & "tbl.className;" & vbCrLf
JSValCode = JSValCode & " if (PrevClass == '')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " PrevClass = 'NoFlashBG';" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " a" & Questions("QuestionId") & "tbl.className = 'FlashBG';" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",500);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='FlashBG'"",1000);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",1500);" & vbCrLf
End If ' optSimpleJS = False
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " if (tmp == 'Cancel')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " tmp = '';" & vbCrLf
'### TEXT AREA ###
ElseIf Questions("TypeId") = 5 Then
JSValCode = JSValCode & " tmp = getTextValue(surveyFrm.q" & Questions("QuestionId") & "," & Questions("Sequence") & ");" & vbCrLf
JSValCode = JSValCode & " if (tmp == null)" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " alert('Please enter your Answer for Question " & Questions("Sequence") & ".');" & vbCrLf
JSValCode = JSValCode & " location.href = 'http://" & Request("SERVER_NAME") & Request("URL") & "?" & Request("QUERY_STRING") & "#Question" & Questions("Sequence") & "';" & vbCrLf
JSValCode = JSValCode & " surveyFrm.q" & Questions("QuestionId") & ".focus();"
If optSimpleJS = False Then
JSValCode = JSValCode & " var PrevClass = a" & Questions("QuestionId") & "tbl.className;" & vbCrLf
JSValCode = JSValCode & " if (PrevClass == '')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " PrevClass = 'NoFlashBG';" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " a" & Questions("QuestionId") & "tbl.className = 'FlashBG';" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",500);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='FlashBG'"",1000);" & vbCrLf
JSValCode = JSValCode & " setTimeout(""a" & Questions("QuestionId") & "tbl.className='""+PrevClass+""'"",1500);" & vbCrLf
End If ' optSimpleJS = False
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " if (tmp == 'Cancel')" & vbCrLf & " {" & vbCrLf
JSValCode = JSValCode & " return false;" & vbCrLf & " }" & vbCrLf
JSValCode = JSValCode & " tmp = '';" & vbCrLf
End If ' end If Questions("TypeId") = 1
Questions.MoveNext
Loop
End If ' end If Questions.RecordCount <> 0
Questions.Filter = ""
If (optUniqueIP = False) OR (optUniqueIP = True AND Sessions.RecordCount <= 0) Then
%>
<%
End If
%>
<%
If Surveys.RecordCount <> 0 Then
%>
<%
Else
%>
Survey is currently unavailable.<%
End If
%><%
Sessions.Close
Set Sessions = Nothing
Options.Close
Set Options = Nothing
Questions.Close
Set Questions = Nothing
Answers.Close
Set Answers = Nothing
Surveys.Close
Set Surveys = Nothing
Conn.Close
Set Conn = Nothing
%>