<% '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 %>
return false;<%Else%>return validateForm(this);<%End If%>">

<%=Surveys("Name")%>

<% If Mode = "Preview" Then %>

<%=strWebsiteTitle%> > <%=strPageTitle%> > Survey Administration > Survey Preview

<% Else %>

<%=strWebsiteTitle%> > <%=strPageTitle%> > <%=Surveys("Name")%>

<% End If If optUniqueIP AND Sessions.RecordCount > 0 Then %>

You have already submitted this survey.

<% Else %> <% If optUseFirstName Then %> <% End If If optUseLastName Then %> <% End If If optUseCompanyName Then %> <% End If If optUseDepartment Then %> <% End If If optUseJobTitle Then %> <% End If If optUseEmail Then %> <% End If If optUsePhone Then %> <% End If %>
* Indicates Required Field
   
<%If optReqFirstName Then%>*<%Else%>  <%End If%> First Name:
<%If optReqLastName Then%>*<%Else%>  <%End If%> Last Name:
<%If optReqCompanyName Then%>*<%Else%>  <%End If%> Company Name:
<%If optReqDepartment Then%>*<%Else%>  <%End If%> Department:
<%If optReqJobTitle Then%>*<%Else%>  <%End If%> Job Title:
<%If optReqEmail Then%>*<%Else%>  <%End If%> Email Address:
<%If optReqPhone Then%>*<%Else%>  <%End If%> Telephone:
<% 'If there are questions, list them. If Questions.RecordCount <> 0 Then Questions.MoveFirst Do While Not Questions.EOF %> <% 'Filter out all answers except for answers that belong to this question. Answers.Filter = "QuestionId = " & Questions("QuestionId") ' If there is a header for this question, display it. If Questions("Header") <> "" Then %> <% End If ' end If Questions("Header") <> "" %> <% 'Reset the filter set previously on Answers. Answers.Filter = "" Questions.MoveNext Loop Else %> <% End If ' end If Questions.RecordCount <> 0 %>
">
<%=Questions("Header")%>
<%If Questions("Required") Then%>* <%End If%><%=Questions("Sequence")%>.  <%=Questions("Question")%>
  <% '############################## BEGIN QUESTION TYPE CHECK ############################## '### RADIO BUTTON ### If Questions("TypeID") = 1 Then 'If there are answers, list them. If Answers.RecordCount <> 0 Then %> tbl" border="0" cellpadding="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <% Do While Not Answers.EOF Call CreateRadio(Questions("QuestionId"),Answers("Answer"),Answers("AnswerId")) Answers.MoveNext Loop %>
<% End If ' end If Answers.RecordCount <> 0 '### TEXT AREA ### ElseIf Questions("TypeID") = 5 Then 'If there are answers, list them. If Answers.RecordCount <> 0 Then %> tbl" border="0" cellpadding="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="100%"><% Do While Not Answers.EOF Call CreateTextArea(Questions("QuestionId"),Answers("Answer"),Answers("AnswerId")) Answers.MoveNext Loop %>
<% End If ' end If Answers.RecordCount <> 0 '### TEXT BOX ### ElseIf Questions("TypeID") = 4 Then 'If there are answers, list them. If Answers.RecordCount <> 0 Then %> tbl" border="0" cellpadding="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="100%"><% Do While Not Answers.EOF Call CreateTextBox(Questions("QuestionId"),Answers("Answer"),Answers("AnswerId")) Answers.MoveNext Loop %>
<% End If ' end If Answers.RecordCount <> 0 '### DROP DOWN ### ElseIf Questions("TypeID") = 3 Then 'If there are answers, list them. If Answers.RecordCount <> 0 Then %> tbl" border="0" cellpadding="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<% End If ' end If Answers.RecordCount <> 0 '### CHECK BOX ### ElseIf Questions("TypeID") = 2 Then 'If there are answers, list them. If Answers.RecordCount <> 0 Then %> tbl" border="0" cellpadding="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <% Do While Not Answers.EOF Call CreateCheck(Questions("QuestionId"),Answers("Answer"),Answers("AnswerId")) Answers.MoveNext Loop %>
<% End If ' end If Answers.RecordCount <> 0 '############################### END QUESTION TYPE CHECK ############################### End If ' end If Questions("TypeID") = 1 %>

There are no questions in this survey.

<% End If %>
<% 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 %>