home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / ReportFilterList.asp < prev    next >
Text File  |  2005-09-28  |  82KB  |  1,459 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.1
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page allows a user to insert, delete, and modify
  7. '                      report filters.
  8. '
  9. '   COPYRIGHT NOTICE
  10. '
  11. '   See attached Software License Agreement
  12. '
  13. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  14. '***********************************************************************
  15. %>
  16. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  17. <!--#Include File="Include/Utility_inc.asp"-->
  18. <!--#Include File="Include/Constants_inc.asp"-->
  19. <!--#Include File="Include/Config_inc.asp"-->
  20. <!--#Include File="Include/ID_inc.asp"-->
  21. <!--#Include File="Include/adovbs_inc.asp"-->
  22. <!--#Include File="Include/CurrentUser_inc.asp"-->
  23. <!--#Include File="Include/ReportShare_inc.asp"-->
  24. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  25.  
  26. <html>
  27. <head>
  28.     <title>Report Filters</title>
  29.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  30. </head>
  31.  
  32. <%
  33.     Dim lngSurveyID
  34.     Dim strSurveyName
  35.     Dim strOriginatingPage
  36.  
  37.     If Len(Request.QueryString("SurveyID")) > 0 Then
  38.         lngSurveyID = Request.QueryString("SurveyID")
  39.         strSurveyName = Request.QueryString("SurveyName")
  40.         strOriginatingPage = Request.QueryString("Nav")
  41.     Else
  42.         lngSurveyID = Request.Form("SurveyID")
  43.         strSurveyName = Request.Form("SurveyName")
  44.         strOriginatingPage = Request.Form("Nav")
  45.     End If
  46.  
  47.     'If the user has access to the overview report, they also have access to the report filters
  48.     If CanUserViewOverviewReport(lngSurveyID) = False Then
  49.         Response.Redirect "AccessDenied.asp?SurveyID=" & lngSurveyID & "&Reason=" & SUR_ACCESS_DENIED_NOT_PERMISSION_TO_PAGE_FILTERS
  50.     End If
  51.  
  52.     Dim rsReportFilters
  53.     Dim rsAnswers
  54.     Dim rsHiddenFields
  55.     Dim rsSubItems
  56.     Dim strSQL
  57.     Dim lngReportFilterCount
  58.     Dim conReportFilter
  59.     Dim conItemDetails
  60.     Dim rsQuestions
  61.     Dim strItemText
  62.     Dim strSelected
  63.     Dim lngItemTypeID
  64.     Dim flgRequired
  65.     Dim lngCurrentReportFilterID
  66.     Dim lngCurrentItemID
  67.     Dim strUserAttributeType
  68.     Dim strCurrentFilterType
  69.     Dim strStartDate
  70.     Dim strEndDate
  71.     Dim lngHiddenFieldID
  72.     Dim strOperatorFirst
  73.     Dim strOperatorSecond
  74.     Dim lngAnswerID
  75.     Dim lngSubItemID
  76.     Dim strAnswerText
  77.     Dim lngCurrentFilterNumber
  78.     Dim flgRenderOtherOption
  79.     Dim strOperatorPrefix
  80.     Dim lngSubItemCount
  81.     Dim lngMinimumValue
  82.     Dim lngMaximumValue
  83.     Dim strAnswerControlName
  84.     Dim lngFirstItemID
  85.     Dim i
  86.     Dim rsItemDetails
  87.     Dim strDatabaseDSN
  88.     Dim strDatabaseSQL
  89.     Dim flgAnswersExist
  90.     Dim strTableRowColor
  91.  
  92.     'Initialization
  93.     Set rsReportFilters = Server.CreateObject("ADODB.Recordset")
  94.     Set rsQuestions = Server.CreateObject("ADODB.Recordset")
  95.     Set rsAnswers = Server.CreateObject("ADODB.Recordset")
  96.     Set rsSubItems = Server.CreateObject("ADODB.Recordset")
  97.     Set rsItemDetails = Server.CreateObject("ADODB.Recordset")
  98.     Set rsHiddenFields = Server.CreateObject("ADODB.Recordset")
  99.     Set conItemDetails = Server.CreateObject("ADODB.Connection")
  100.     Set conReportFilter = Server.CreateObject("ADODB.Connection")
  101.     conReportFilter.Open SURVEY_APP_CONNECTION
  102.     lngCurrentFilterNumber = 1
  103.  
  104.     'Initialize the row color
  105.     strTableRowColor = "TableRowLightColor"
  106. %>
  107.  
  108. <script language ="JavaScript" src="ClientInclude/Utility.js"></script>
  109. <script language="JavaScript">
  110. function deleteReportFilter(lngReportFilterID)
  111. {
  112.     if (validateAllFilters(lngReportFilterID) == true)
  113.     {
  114.         if (confirm("Are you sure you want to delete this report filter?") == true) //OK
  115.         {
  116.             document.forms['frmReportFilter'].ActionAfterSave.value = '<%=SUR_REPORT_FILTER_ACTION_DELETE%>';
  117.             document.forms['frmReportFilter'].ReportFilterID.value = lngReportFilterID;
  118.             document.forms['frmReportFilter'].submit();
  119.         }
  120.     }
  121. }
  122.  
  123. function validateAllFilters(lngReportFilterIDToBeDeleted)
  124. {
  125.     var strTemp;
  126.     var i;
  127.  
  128.     // Dynamically check the format of all number and date text boxes
  129.     if (document.forms['frmReportFilter'] != null)
  130.     {
  131.         for (i = 0; i < document.forms['frmReportFilter'].length; i++)
  132.         {
  133.             strTemp = document.forms['frmReportFilter'].elements[i].name;
  134.             if (strTemp.indexOf('txtAnswerNumber') > -1 && strTemp.indexOf(lngReportFilterIDToBeDeleted) == -1)
  135.             {
  136.                 strTemp = trim(document.forms['frmReportFilter'].elements[i].value);
  137.                 if (strTemp.length > 0)
  138.                 {
  139.                     // Make sure the value entered is numeric
  140.                     if (isNumeric(trim(document.forms['frmReportFilter'].elements[i].value)) == false)
  141.                     {
  142.                         alert("Please make sure that value entered for each number question is numeric.");
  143.                         document.forms['frmReportFilter'].elements[i].focus();
  144.                         return;
  145.                     }
  146.                 }
  147.                 else
  148.                 {
  149.                     alert("Please enter a numeric value for each number question.");
  150.                     document.forms['frmReportFilter'].elements[i].focus();
  151.                     return;
  152.                 }
  153.             }
  154.             else if (strTemp.indexOf('txtAnswerDate') > -1 && strTemp.indexOf(lngReportFilterIDToBeDeleted) == -1)
  155.             {
  156.                 strTemp = trim(document.forms['frmReportFilter'].elements[i].value);
  157.                 if (strTemp.length > 0)
  158.                 {
  159.                     // Make sure the value entered is a valid date
  160.                     if (<%=RenderJSDateValidationRoutineName%>(trim(document.forms['frmReportFilter'].elements[i].value)) == false)
  161.                     {
  162.                         document.forms['frmReportFilter'].elements[i].focus();
  163.                         return;
  164.                     }
  165.                 }
  166.                 else
  167.                 {
  168.                     alert("Please enter a date value for each date question.");
  169.                     document.forms['frmReportFilter'].elements[i].focus();
  170.                     return;
  171.                 }
  172.             }
  173.             else if (strTemp.indexOf('txtStartDate') > -1 && strTemp.indexOf(lngReportFilterIDToBeDeleted) == -1)
  174.             {
  175.                 strTemp = trim(document.forms['frmReportFilter'].elements[i].value);
  176.                 if (strTemp.length > 0)
  177.                 {
  178.                     // Make sure the value entered is a valid date
  179.                     if (<%=RenderJSDateValidationRoutineName%>(trim(document.forms['frmReportFilter'].elements[i].value)) == false)
  180.                     {
  181.                         document.forms['frmReportFilter'].elements[i].focus();
  182.                         return;
  183.                     }
  184.                 }
  185.             }
  186.             else if (strTemp.indexOf('txtEndDate') > -1 && strTemp.indexOf(lngReportFilterIDToBeDeleted) == -1)
  187.             {
  188.                 strTemp = trim(document.forms['frmReportFilter'].elements[i].value);
  189.                 if (strTemp.length > 0)
  190.                 {
  191.                     // Make sure the value entered is a valid date
  192.                     if (<%=RenderJSDateValidationRoutineName%>(trim(document.forms['frmReportFilter'].elements[i].value)) == false)
  193.                     {
  194.                         document.forms['frmReportFilter'].elements[i].focus();
  195.                         return;
  196.                     }
  197.                 }
  198.             }
  199.         }
  200.     }
  201.  
  202.     return true;
  203. }
  204.  
  205. function questionSelected()
  206. {
  207.     document.forms['frmReportFilter'].action = 'ReportFilterList.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>';
  208.     document.forms['frmReportFilter'].submit();
  209. }
  210.  
  211. function filterTypeSelected()
  212. {
  213.     document.forms['frmReportFilter'].action = 'ReportFilterList.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>';
  214.     document.forms['frmReportFilter'].submit();
  215. }
  216.  
  217. function answerSelected(strAnswerValue, strRefreshFlag)
  218. {
  219.     if (strAnswerValue == '<%=SUR_CONTROL_OTHER%>' || strRefreshFlag == 'True')
  220.     {
  221.         document.forms['frmReportFilter'].action = 'ReportFilterList.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>';
  222.         document.forms['frmReportFilter'].submit();
  223.     }
  224. }
  225.  
  226. function submitCheck()
  227. {
  228.     // Check to make sure that all filters are valid before submitting the page
  229.     if (validateAllFilters('-1') == true)
  230.     {
  231.         document.forms['frmReportFilter'].submit();
  232.     }
  233. }
  234.  
  235. function insertFilter()
  236. {
  237.     if (validateAllFilters('-1') == true)
  238.     {
  239.         document.forms['frmReportFilter'].ActionAfterSave.value = '<%=SUR_REPORT_FILTER_ACTION_INSERT%>';
  240.         document.forms['frmReportFilter'].submit();
  241.     }
  242. }
  243. </script>
  244.  
  245. <body class="MainBodyStyle">
  246.  
  247. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  248.  
  249. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  250.     <tr>
  251.         <td height="36" valign="center">
  252.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Report Filters</a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#ReportFilters', null, 'menubar=no,toolbar=no,titlebar=no,status=no,left=10,top=10,scrollbars=yes,resizable=yes,height=550,width=770');" border="0" src="Resources/Images/Help.gif">
  253.         </td>
  254.     </tr>
  255. </table>
  256.  
  257. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  258.  
  259. <form method="post" name="frmReportFilter" onSubmit="return submitCheck();" action="ReportFilterListAction.asp">
  260.     <input type="hidden" name="SurveyID" value="<%=lngSurveyID%>">
  261.     <input type="hidden" name="SurveyName" value="<%=strSurveyName%>">
  262.     <input type="hidden" name="DisplayHeader" value="<%=Request.QueryString("DisplayHeader")%>">
  263.     <input type="hidden" name="Nav" value="<%=strOriginatingPage%>">
  264.     <input type="hidden" name="ActionAfterSave" value="">
  265.     <input type="hidden" name="ReportFilterID" value="">
  266.     <table width="740" border="0" cellpadding="6" cellspacing="0" class="LightGrayBackgroundColor">
  267.         <tr>
  268.             <td width="1" rowspan="25"></td>
  269.             <td height="38" valign="center">
  270.                 <span class="H2HeadingStyle">Report Filters for '<%=strSurveyName%>' Survey</span>
  271.             </td>
  272.             <td width="1" rowspan="25"> </td>
  273.         </tr>
  274.         <tr>
  275.             <td valign="top" height="44">
  276.                 <span class="Normal">
  277.                 Add as many report filters to this survey as desired.  The overview and individual reports will then
  278.                 display only those responses that match <i>all</i> of the filters listed below.
  279.                 </span>
  280.             </td>
  281.         </tr>
  282.     </table>
  283.     <table border="0" cellpadding="6" cellspacing="0" width="740" class="WhiteBackgroundColor" summary="This page displays a list of all report filters for the selected survey.">
  284. <%
  285.         'Create a recordset of all the questions for this survey.  This recordset is used inside the loop
  286.         'for report filters to create a combo of questions to pick from.
  287.         strSQL = "SELECT i.item_id, i.item_type_id, required_yn, item_text " & _
  288.                     "FROM sur_item i, sur_survey_to_item_mapping m, sur_item_type it " & _
  289.                     "WHERE i.item_id = m.item_id " & _
  290.                     "AND i.item_type_id = it.item_type_id " & _
  291.                     "AND it.question_yn = " & SQLEncode(SUR_BOOLEAN_POSITIVE) & _
  292.                     " AND m.survey_id = " & lngSurveyID & _
  293.                     " ORDER BY m.order_number"
  294.         rsQuestions.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenStatic, , adCmdText
  295.  
  296.         'Create a recordset of all the hidden fields for this survey
  297.         strSQL = "SELECT hidden_field_id, hidden_field_display_name " & _
  298.                     "FROM sur_hidden_field " & _
  299.                     "WHERE survey_id = " & lngSurveyID & _
  300.                     " ORDER BY order_number"
  301.         rsHiddenFields.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenStatic, , adCmdText
  302.  
  303.         'Get the existing report filters for this page
  304.         strSQL = "SELECT report_filter_id, filtered_item_id, user_attribute_type, filter_type, " & _
  305.                  "operator_first, operator_second, subitem_id, start_date, end_date, hidden_field_id, answer_id, " & _
  306.                  "active_yn, other_yn, answer_text " & _
  307.                  "FROM sur_report_filter " & _
  308.                  "WHERE survey_id = " & lngSurveyID
  309.         If GetUsername() = SUR_ANONYMOUS_USER Then
  310.             strSQL = strSQL & " AND user_id = " & SUR_ANONYMOUS_USER_ID
  311.         Else
  312.             strSQL = strSQL & " AND user_id = " & GetUserID()
  313.         End If
  314.         strSQL = strSQL & " ORDER BY order_number"
  315.         Set rsReportFilters = conReportFilter.Execute(ConvertSQL(strSQL), , adCmdText)
  316. %>
  317.         <tr class="TableHeadingColor" height="40">
  318.             <th id="ID" width="25" align="center" valign="center">
  319.                 <span class="TableHeadingBold">#</span>
  320.             </th>
  321.             <th id="Active" width="50" align="center" valign="center">
  322.                 <span class="TableHeadingBold">Active</span>
  323.             </th>
  324.             <th id="Delete" width="60" align="center" valign="center">
  325.                 <span class="TableHeadingBold">Delete</span>
  326.             </th>
  327.             <th id="Details" align="center" width="605" valign="center">
  328.                 <span class="TableHeadingBold">Filter Details</span>
  329.             </th>
  330.         </tr>
  331. <%
  332.         'If there are no existing report filters, display a message to that effect
  333.         If rsReportFilters.EOF = True Then
  334.             lngReportFilterCount = 0
  335. %>
  336.             <tr class="TableRowLightColor">
  337.                 <td colspan="4">
  338.                     <span class="InlineHelpSpanStyle">There are no report filters for this survey.</span>
  339.                 </td>
  340.             </tr>
  341. <%
  342.         Else 'There are existing report filters
  343.             rsReportFilters.MoveFirst
  344.             Do While Not rsReportFilters.EOF
  345.                 lngCurrentReportFilterID = rsReportFilters("report_filter_id")
  346.                 lngReportFilterCount = lngReportFilterCount + 1
  347.                 flgAnswersExist = True
  348. %>
  349.                 <tr class="<%=strTableRowColor%>">
  350.                     <td align="center" valign="center">
  351.                         <span class="NormalBold"><label for="chkActive<%=lngCurrentReportFilterID%>"><%=lngCurrentFilterNumber%></label></span>
  352.                     </td>
  353.                     <td align="center" valign="center">
  354.                         <input type="checkbox" <% If rsReportFilters("active_yn") = SUR_BOOLEAN_POSITIVE Then Response.Write "checked" End If %> name="chkActive<%=lngCurrentReportFilterID%>" id="chkActive<%=lngCurrentReportFilterID%>">
  355.                     </td>
  356.                     <td align="center">
  357.                         <a href="javascript:deleteReportFilter('<%=lngCurrentReportFilterID%>');"><img alt="Delete this report filter" border="0" src="Resources/Icons/Delete.gif" onMouseOver="this.style.cursor='hand'"></a>
  358.                     </td>
  359.                     <td>
  360.                         <table cellpadding="2" cellspacing="0" border="0" width="100%">
  361.                             <tr>
  362.                                 <td width="125">
  363.                                     <span class="Normal"><label for="cboFilterType<%=lngCurrentReportFilterID%>">Select filter type</label></span>
  364.                                 </td>
  365.                                 <td width="440">
  366. <%
  367.                                     'If the value for this filter exists in the posted form collection, use that value; otherwise, use
  368.                                     'the value from the database
  369.                                     If Len(Request.Form("cboFilterType" & CStr(lngCurrentReportFilterID))) > 0 Then
  370.                                         strCurrentFilterType = Request.Form("cboFilterType" & CStr(lngCurrentReportFilterID))
  371.                                         strStartDate = Request.Form("txtStartDate" & CStr(lngCurrentReportFilterID))
  372.                                         strEndDate = Request.Form("txtEndDate" & CStr(lngCurrentReportFilterID))
  373.                                         lngHiddenFieldID = Request.Form("cboHiddenField" & CStr(lngCurrentReportFilterID))
  374.                                     Else
  375.                                         strCurrentFilterType = rsReportFilters("filter_type")
  376.                                         strStartDate = CustomDateFormatDisplay(rsReportFilters("start_date"))
  377.                                         strEndDate = CustomDateFormatDisplay(rsReportFilters("end_date"))
  378.                                         lngHiddenFieldID = rsReportFilters("hidden_field_id")
  379.                                     End If
  380. %>
  381.                                     <select name="cboFilterType<%=lngCurrentReportFilterID%>" id="cboFilterType<%=lngCurrentReportFilterID%>" style="width:256px" onChange="javascript:filterTypeSelected();">
  382.                                         <option <% If strCurrentFilterType = SUR_REPORT_FILTER_TYPE_DATE Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_TYPE_DATE%>"><%=SUR_REPORT_FILTER_TYPE_DATE%></option>
  383. <%
  384.                                         'Only display the hidden field option in the dropdown if the survey has hidden fields
  385.                                         If CLng(GetHiddenFieldCount(lngSurveyID)) > 0 Then
  386. %>
  387.                                             <option <% If strCurrentFilterType = SUR_REPORT_FILTER_TYPE_HIDDEN_FIELD Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_TYPE_HIDDEN_FIELD%>"><%=SUR_REPORT_FILTER_TYPE_HIDDEN_FIELD%></option>
  388. <%
  389.                                         End If
  390. %>
  391.                                         <option <% If strCurrentFilterType = SUR_REPORT_FILTER_TYPE_QUESTION Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_TYPE_QUESTION%>"><%=SUR_REPORT_FILTER_TYPE_QUESTION%></option>
  392.                                         <option <% If strCurrentFilterType = SUR_REPORT_FILTER_TYPE_USER_ATTRIBUTE Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_TYPE_USER_ATTRIBUTE%>"><%=SUR_REPORT_FILTER_TYPE_USER_ATTRIBUTE%></option>
  393.                                     </select>
  394.                                 </td>
  395.                             </tr>
  396. <%
  397.                             'Display the appropriate set of input controls, depending on the filter type selected
  398.                             If strCurrentFilterType = SUR_REPORT_FILTER_TYPE_DATE Then
  399. %>
  400.                                 <tr>
  401.                                     <td>
  402.                                         <span class="Normal"><label for="txtStartDate<%=lngCurrentReportFilterID%>">Enter start date</label></span>
  403.                                     </td>
  404.                                     <td>
  405.                                         <input value="<%=strStartDate%>" type="text" style="width:150px" name="txtStartDate<%=lngCurrentReportFilterID%>" id="txtStartDate<%=lngCurrentReportFilterID%>"> <span class="InlineHelpSpanStyle">mm/dd/yyyy</span>
  406.                                     </td>
  407.                                 </tr>
  408.                                 <tr>
  409.                                     <td>
  410.                                         <span class="Normal"><label for="txtEndDate<%=lngCurrentReportFilterID%>">Enter end date</label></span>
  411.                                     </td>
  412.                                     <td>
  413.                                         <input value="<%=strEndDate%>" type="text" style="width:150px" name="txtEndDate<%=lngCurrentReportFilterID%>" id="txtEndDate<%=lngCurrentReportFilterID%>"> <span class="InlineHelpSpanStyle">mm/dd/yyyy</span>
  414.                                     </td>
  415.                                 </tr>
  416. <%
  417.                             ElseIf strCurrentFilterType = SUR_REPORT_FILTER_TYPE_HIDDEN_FIELD Then
  418. %>
  419.                                 <tr>
  420.                                     <td>
  421.                                         <span class="Normal"><label for="cboHiddenField<%=lngCurrentReportFilterID%>">Select hidden field</label></span>
  422.                                     </td>
  423.                                     <td>
  424.                                         <select style="width:400px" name="cboHiddenField<%=lngCurrentReportFilterID%>">
  425. <%
  426.                                             If Len(Request.Form("cboHiddenField" & lngCurrentReportFilterID)) > 0 Then
  427.                                                 lngHiddenFieldID = Request.Form("cboHiddenField" & lngCurrentReportFilterID)
  428.                                             Else
  429.                                                 lngHiddenFieldID = rsReportFilters("hidden_field_id")
  430.                                             End If
  431.  
  432.                                             rsHiddenFields.MoveFirst
  433.                                             Do While Not rsHiddenFields.EOF
  434.                                                 strSelected = ""
  435.                                                 '--9/26/05 added & "" to end of CStr because of invalid use of null error with CStr.
  436. %>
  437.                                                 <option <% If CStr(lngHiddenFieldID & "") = CStr(rsHiddenFields("hidden_field_id") & "") Then Response.Write "selected" End If %> value="<%=rsHiddenFields("hidden_field_id")%>"><%=rsHiddenFields("hidden_field_display_name")%></option>
  438. <%
  439.                                                 rsHiddenFields.MoveNext
  440.                                             Loop
  441. %>
  442.                                         </select>
  443.                                     </td>
  444.                                 </tr>
  445.                                 <tr>
  446.                                     <td>
  447.                                         <span class="Normal"><label for="cboOperatorFirst<%=lngCurrentReportFilterID%>"><label for="cboOperatorSecond<%=lngCurrentReportFilterID%>">Include records</label></label></span>
  448.                                     </td>
  449.                                     <td>
  450. <%
  451.                                         'Capture the first operator for the current record, to use for comparisons.  If the field is
  452.                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  453.                                         If Len(Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))) > 0 Then
  454.                                             strOperatorFirst = Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))
  455.                                         Else
  456.                                             strOperatorFirst = rsReportFilters("operator_first")
  457.                                         End If
  458. %>
  459.                                         <select style="width:125px" name="cboOperatorFirst<%=lngCurrentReportFilterID%>" id="Select1">
  460.                                             <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%></option>
  461.                                             <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%></option>
  462.                                         </select>
  463. <%
  464.                                         'Capture the second operator for the current record, to use for comparisons.  If the field is
  465.                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  466.                                         If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  467.                                             strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  468.                                         Else
  469.                                             strOperatorSecond = rsReportFilters("operator_second")
  470.                                         End If
  471. %>
  472.                                         <select style="width:125px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="Select2">
  473.                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%></option>
  474.                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%></option>
  475.                                         </select>
  476. <%
  477.                                         'Capture the answer text for the current record, to use for comparisons.  If the field is
  478.                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  479.                                         If Len(Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  480.                                             strAnswerText = Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))
  481.                                         Else
  482.                                             strAnswerText = rsReportFilters("answer_text")
  483.                                         End If
  484. %>
  485.                                         <input value="<%=strAnswerText%>" type="text" style="width:135px" name="txtAnswer<%=lngCurrentReportFilterID%>" id="Text1" maxlength="50">
  486.                                     </td>
  487. <%
  488.                             ElseIf strCurrentFilterType = SUR_REPORT_FILTER_TYPE_USER_ATTRIBUTE Then
  489. %>
  490.                                 <tr>
  491.                                     <td>
  492.                                         <span class="Normal"><label for="cboUserAttributeType<%=lngCurrentReportFilterID%>">Select attribute</label></span>
  493.                                     </td>
  494.                                     <td>
  495. <%
  496.                                         'Capture the user attribute type for the current record, to use for comparisons.  If the field is
  497.                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  498.                                         If Len(Request.Form("cboUserAttributeType")) > 0 Then
  499.                                             strUserAttributeType = Request.Form("cboUserAttributeType")
  500.                                         Else
  501.                                             strUserAttributeType = rsReportFilters("user_attribute_type")
  502.                                         End If
  503. %>
  504.                                         <select name="cboUserAttributeType<%=lngCurrentReportFilterID%>" id="cboUserAttributeType<%=lngCurrentReportFilterID%>" style="width:256px">
  505.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_COMPANY Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_COMPANY%>"><%=SUR_USER_ATTRIBUTE_TYPE_COMPANY%></option>
  506.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_1 Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_1%>"><%=SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_1%></option>
  507.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_2 Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_2%>"><%=SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_2%></option>
  508.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_3 Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_3%>"><%=SUR_USER_ATTRIBUTE_TYPE_CUSTOM_DATA_3%></option>
  509.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_EMAIL_ADDRESS Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_EMAIL_ADDRESS%>"><%=SUR_USER_ATTRIBUTE_TYPE_EMAIL_ADDRESS%></option>
  510.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_FIRST_NAME Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_FIRST_NAME%>"><%=SUR_USER_ATTRIBUTE_TYPE_FIRST_NAME%></option>
  511.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_LAST_NAME Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_LAST_NAME%>"><%=SUR_USER_ATTRIBUTE_TYPE_LAST_NAME%></option>
  512.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_LOCATION Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_LOCATION%>"><%=SUR_USER_ATTRIBUTE_TYPE_LOCATION%></option>
  513.                                             <option <% If strUserAttributeType = SUR_USER_ATTRIBUTE_TYPE_POSITION Then Response.Write "selected" End If %> value="<%=SUR_USER_ATTRIBUTE_TYPE_POSITION%>"><%=SUR_USER_ATTRIBUTE_TYPE_POSITION%></option>
  514.                                         </select>
  515.                                     </td>
  516.                                 </tr>
  517.                                 <tr>
  518.                                     <td>
  519.                                         <span class="Normal"><label for="cboOperatorFirst<%=lngCurrentReportFilterID%>"><label for="cboOperatorSecond<%=lngCurrentReportFilterID%>">Include records</label></label></span>
  520.                                     </td>
  521.                                     <td>
  522. <%
  523.                                         'Capture the first operator for the current record, to use for comparisons.  If the field is
  524.                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  525.                                         If Len(Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))) > 0 Then
  526.                                             strOperatorFirst = Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))
  527.                                         Else
  528.                                             strOperatorFirst = rsReportFilters("operator_first")
  529.                                         End If
  530. %>
  531.                                         <select style="width:125px" name="cboOperatorFirst<%=lngCurrentReportFilterID%>" id="cboOperatorFirst<%=lngCurrentReportFilterID%>">
  532.                                             <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%></option>
  533.                                             <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%></option>
  534.                                         </select>
  535. <%
  536.                                         'Capture the second operator for the current record, to use for comparisons.  If the field is
  537.                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  538.                                         If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  539.                                             strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  540.                                         Else
  541.                                             strOperatorSecond = rsReportFilters("operator_second")
  542.                                         End If
  543. %>
  544.                                         <select style="width:125px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  545.                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%></option>
  546.                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%></option>
  547.                                         </select>
  548. <%
  549.                                         'Capture the answer text for the current record, to use for comparisons.  If the field is
  550.                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  551.                                         If Len(Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  552.                                             strAnswerText = Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))
  553.                                         Else
  554.                                             strAnswerText = rsReportFilters("answer_text")
  555.                                         End If
  556. %>
  557.                                         <input value="<%=strAnswerText%>" type="text" style="width:135px" name="txtAnswer<%=lngCurrentReportFilterID%>" id="txtAnswer<%=lngCurrentReportFilterID%>" maxlength="50">
  558.                                     </td>
  559. <%
  560.                             ElseIf strCurrentFilterType = SUR_REPORT_FILTER_TYPE_QUESTION Then
  561. %>
  562.                                 <tr>
  563.                                     <td>
  564.                                         <span class="Normal"><label for="cboQuestion<%=lngCurrentReportFilterID%>">Select question</label></span>
  565.                                     </td>
  566.                                     <td>
  567.                                         <select style="width:400px" name="cboQuestion<%=lngCurrentReportFilterID%>" id="cboQuestion<%=lngCurrentReportFilterID%>" onChange="questionSelected();">
  568. <%
  569.                                             rsQuestions.MoveFirst
  570.                                             lngFirstItemID = rsQuestions("item_id")
  571.                                             Do While Not rsQuestions.EOF
  572.                                                 'Limit the length of the question, in case it's a long question
  573.                                                 strItemText = rsQuestions("item_text")
  574.  
  575.                                                 'If there is not an item in the form collection for this value, set the current item ID
  576.                                                 'equal to the item ID in the database.  Otherwise, use the value posted back in the form.
  577.                                                 If Len(Request.Form("cboQuestion" & CStr(lngCurrentReportFilterID))) > 0 Then
  578.                                                     lngCurrentItemID = Request.Form("cboQuestion" & CStr(lngCurrentReportFilterID))
  579.                                                 Else
  580.                                                     'If the item ID is null, use the first item in the list of questions
  581.                                                     If IsNull(rsReportFilters("filtered_item_id")) = True Then
  582.                                                         lngCurrentItemID = lngFirstItemID
  583.                                                     Else
  584.                                                         lngCurrentItemID = rsReportFilters("filtered_item_id")
  585.                                                     End If
  586.                                                 End If
  587.  
  588.                                                 'If the current question in the questions list is the same as the question
  589.                                                 'selected for this item, mark it as selected and capture the item type and
  590.                                                 'whether or not this question is required
  591.                                                 If CStr(rsQuestions("item_id")) = CStr(lngCurrentItemID) Then
  592.                                                     strSelected = "SELECTED"
  593.                                                     lngItemTypeID = rsQuestions("item_type_id")
  594.                                                     flgRequired = rsQuestions("required_yn")
  595.                                                 Else
  596.                                                     strSelected = ""
  597.                                                 End If
  598. %>
  599.                                                 <option <%=strSelected%> value="<%=rsQuestions("item_id")%>"><%=strItemText%></option>
  600. <%
  601.                                                 rsQuestions.MoveNext
  602.                                             Loop
  603. %>
  604.                                         </select>
  605.                                         <input type="hidden" value="<%=lngItemTypeID%>" name="ItemTypeID<%=lngCurrentReportFilterID%>">
  606.                                     </td>
  607.                                 </tr>
  608.                                 <tr>
  609.                                     <td>
  610. <%
  611.                                         'Display the appropriate row heading depending on the type of question
  612.                                         If CLng(lngItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngItemTypeID) = SUR_ITEM_DATABASE_DROPDOWN Or CLng(lngItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Or CLng(lngItemTypeID) = SUR_ITEM_YES_NO Or CLng(lngItemTypeID) = SUR_ITEM_TRUE_FALSE Then
  613. %>
  614.                                             <span class="Normal">Select answer</span>
  615. <%
  616.                                         ElseIf CLng(lngItemTypeID) = SUR_ITEM_CONSTANT_SUM Or CLng(lngItemTypeID) = SUR_ITEM_RANKING Or CLng(lngItemTypeID) = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or CLng(lngItemTypeID) = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or CLng(lngItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Or CLng(lngItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Or CLng(lngItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Then
  617. %>
  618.                                             <span class="Normal">Select row</span>
  619. <%
  620.                                         Else
  621. %>
  622.                                             <span class="Normal">Include records</span>
  623. <%
  624.                                         End If
  625. %>
  626.                                     </td>
  627.                                     <td>
  628. <%
  629.                                         Select Case CLng(lngItemTypeID)
  630.                                             Case SUR_ITEM_DATE, SUR_ITEM_NUMBER
  631.                                                 'Capture the second operator for the current record, to use for comparisons.  If the field is
  632.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  633.                                                 If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  634.                                                     strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  635.                                                 Else
  636.                                                     strOperatorSecond = rsReportFilters("operator_second")
  637.                                                 End If
  638.  
  639.                                                 If CLng(lngItemTypeID) = SUR_ITEM_CONSTANT_SUM Then
  640.                                                     strOperatorPrefix = "where sum is "
  641.                                                 ElseIf CLng(lngItemTypeID) = SUR_ITEM_DATE Or CLng(lngItemTypeID) = SUR_ITEM_NUMBER Then
  642.                                                     strOperatorPrefix = "that are "
  643.                                                 Else
  644.                                                     strOperatorPrefix = ""
  645.                                                 End If
  646. %>
  647.                                                 <select style="width:256px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  648.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%></option>
  649.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%></option>
  650.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%></option>
  651.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%></option>
  652.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%></option>
  653.                                                 </select>
  654. <%
  655.                                             Case SUR_ITEM_OPEN_ENDED_ONE_LINE, SUR_ITEM_OPEN_ENDED_COMMENTS_BOX
  656.                                                 'Capture the first operator for the current record, to use for comparisons.  If the field is
  657.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  658.                                                 If Len(Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))) > 0 Then
  659.                                                     strOperatorFirst = Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))
  660.                                                 Else
  661.                                                     strOperatorFirst = rsReportFilters("operator_first")
  662.                                                 End If
  663. %>
  664.                                                 <select style="width:125px" name="cboOperatorFirst<%=lngCurrentReportFilterID%>" id="cboOperatorFirst<%=lngCurrentReportFilterID%>">
  665.                                                     <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%></option>
  666.                                                     <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%></option>
  667.                                                 </select>
  668. <%
  669.                                                 'Capture the second operator for the current record, to use for comparisons.  If the field is
  670.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  671.                                                 If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  672.                                                     strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  673.                                                 Else
  674.                                                     strOperatorSecond = rsReportFilters("operator_second")
  675.                                                 End If
  676. %>
  677.                                                 <select style="width:125px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  678.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%></option>
  679.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%></option>
  680.                                                 </select>
  681. <%
  682.                                             Case SUR_ITEM_YES_NO
  683.                                                 'Capture the answer text for the current record, to use for comparisons.  If the field is
  684.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  685.                                                 If Len(Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  686.                                                     strAnswerText = Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))
  687.                                                 Else
  688.                                                     strAnswerText = rsReportFilters("answer_text")
  689.                                                 End If
  690. %>
  691.                                                 <select style="width:256px" name="cboAnswer<%=lngCurrentReportFilterID%>" id="cboAnswer<%=lngCurrentReportFilterID%>">
  692.                                                     <option <% If strAnswerText = SUR_YES_NO_QUESTION_VALUE_NO Then Response.Write "selected" End If %> value="<%=SUR_YES_NO_QUESTION_VALUE_NO%>"><%=SUR_YES_NO_QUESTION_VALUE_NO%></option>
  693.                                                     <option <% If strAnswerText = SUR_YES_NO_QUESTION_VALUE_YES Then Response.Write "selected" End If %> value="<%=SUR_YES_NO_QUESTION_VALUE_YES%>"><%=SUR_YES_NO_QUESTION_VALUE_YES%></option>
  694.                                                 </select>
  695. <%
  696.                                             Case SUR_ITEM_TRUE_FALSE
  697.                                                 'Capture the answer text for the current record, to use for comparisons.  If the field is
  698.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  699.                                                 If Len(Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  700.                                                     strAnswerText = Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))
  701.                                                 Else
  702.                                                     strAnswerText = rsReportFilters("answer_text")
  703.                                                 End If
  704. %>
  705.                                                 <select style="width:256px" name="cboAnswer<%=lngCurrentReportFilterID%>" id="cboAnswer<%=lngCurrentReportFilterID%>">
  706.                                                     <option <% If strAnswerText = SUR_TRUE_FALSE_QUESTION_VALUE_FALSE Then Response.Write "selected" End If %> value="<%=SUR_TRUE_FALSE_QUESTION_VALUE_FALSE%>"><%=SUR_TRUE_FALSE_QUESTION_VALUE_FALSE%></option>
  707.                                                     <option <% If strAnswerText = SUR_TRUE_FALSE_QUESTION_VALUE_TRUE Then Response.Write "selected" End If %> value="<%=SUR_TRUE_FALSE_QUESTION_VALUE_TRUE%>"><%=SUR_TRUE_FALSE_QUESTION_VALUE_TRUE%></option>
  708.                                                 </select>
  709. <%
  710.                                             Case SUR_ITEM_SINGLE_SELECT_DROPDOWN, SUR_ITEM_SINGLE_SELECT_OPTIONS, SUR_ITEM_MULTISELECT_CHECKBOXES
  711.                                                 'Select all of the answers for the question.
  712.                                                 strSQL = "SELECT answer_id, other_yn, answer_text " & _
  713.                                                             "FROM sur_item_answer ia, sur_item i " & _
  714.                                                             "WHERE ia.item_id = i.item_id " & _
  715.                                                             "AND i.item_id = " & lngCurrentItemID & _
  716.                                                             " ORDER BY order_number"
  717.                                                 rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  718.                                                 rsAnswers.MoveFirst
  719.  
  720.                                                 'Capture the answer ID for the current record, to use for comparisons.  If the field is
  721.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  722.                                                 If Len(Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  723.                                                     lngAnswerID = Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))
  724.                                                 Else
  725.                                                     'Check to see if the answer selected was for the "Other" choice
  726.                                                     If rsReportFilters("other_yn") = SUR_BOOLEAN_POSITIVE Then
  727.                                                         lngAnswerID = SUR_CONTROL_OTHER
  728.                                                     Else
  729.                                                         'If there is no subitem ID in either the database or a submitted form, use
  730.                                                         'the first subitem
  731.                                                         lngAnswerID = rsReportFilters("answer_id")
  732.                                                         If IsNull(lngAnswerID) = True Or Len(Trim(lngAnswerID)) = 0 Then
  733.                                                             lngAnswerID = rsAnswers("answer_id")
  734.                                                         End If
  735.                                                     End If
  736.                                                 End If
  737.  
  738.                                                 'Capture whether or not this question has an "Other" option
  739.                                                 If rsAnswers("other_yn") = SUR_BOOLEAN_POSITIVE Then
  740.                                                     flgRenderOtherOption = True
  741.                                                 Else
  742.                                                     flgRenderOtherOption = False
  743.                                                 End If
  744. %>
  745.                                                 <select style="width:256px" name="cboAnswer<%=lngCurrentReportFilterID%>" id="cboAnswer<%=lngCurrentReportFilterID%>" onChange="javascript:answerSelected(this.value, '<% If CStr(lngAnswerID) = SUR_CONTROL_OTHER Then Response.Write "True" Else Response.Write "False" End If %>');">
  746. <%
  747.                                                     Do While Not rsAnswers.EOF
  748. %>
  749.                                                         <option <% If CStr(rsAnswers("answer_id")) = CStr(lngAnswerID) Then Response.Write "SELECTED" End If %> value="<%=rsAnswers("answer_id")%>"><%=rsAnswers("answer_text")%></option>
  750. <%
  751.                                                         rsAnswers.MoveNext
  752.                                                     Loop
  753.                                                     rsAnswers.Close
  754.  
  755.                                                     'If there is an "Other" choice, add it to the dropdown
  756.                                                     If flgRenderOtherOption = True Then
  757. %>
  758.                                                         <option <% If lngAnswerID = SUR_CONTROL_OTHER Then Response.Write "selected" End If %> value="<%=SUR_CONTROL_OTHER%>"><%=SUR_CONTROL_OTHER%></option>
  759. <%
  760.                                                     End If
  761. %>
  762.                                                 </select>
  763. <%
  764.                                                 'If the "Other" choice was selected, display the controls for the "Other".  Make sure this is not a
  765.                                                 'dropdown, which it could appear to be if switching from a checkbox or option control that had "Other"
  766.                                                 'selected.
  767.                                                 If lngAnswerID = SUR_CONTROL_OTHER And CLng(lngItemTypeID) <> SUR_ITEM_SINGLE_SELECT_DROPDOWN Then
  768. %>
  769.                                                         </td>
  770.                                                     <tr>
  771.                                                     <tr>
  772.                                                         <td>
  773.                                                             <span class="Normal">Include records</span>
  774.                                                         </td>
  775.                                                         <td>
  776. <%
  777.                                                             'Capture the answer text for the current record, to use for comparisons.  If the field is
  778.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  779.                                                             If Len(Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  780.                                                                 strAnswerText = Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))
  781.                                                             Else
  782.                                                                 strAnswerText = rsReportFilters("answer_text")
  783.                                                             End If
  784.  
  785.                                                             'Capture the first operator for the current record, to use for comparisons.  If the field is
  786.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  787.                                                             If Len(Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))) > 0 Then
  788.                                                                 strOperatorFirst = Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))
  789.                                                             Else
  790.                                                                 strOperatorFirst = rsReportFilters("operator_first")
  791.                                                             End If
  792. %>
  793.                                                             <select style="width:125px" name="cboOperatorFirst<%=lngCurrentReportFilterID%>" id="cboOperatorFirst<%=lngCurrentReportFilterID%>">
  794.                                                                 <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%></option>
  795.                                                                 <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%></option>
  796.                                                             </select>
  797. <%
  798.                                                             'Capture the second operator for the current record, to use for comparisons.  If the field is
  799.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  800.                                                             If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  801.                                                                 strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  802.                                                             Else
  803.                                                                 strOperatorSecond = rsReportFilters("operator_second")
  804.                                                             End If
  805. %>
  806.                                                             <select style="width:125px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  807.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%></option>
  808.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%></option>
  809.                                                             </select>
  810. <%
  811.                                                 End If
  812.                                             Case SUR_ITEM_DATABASE_DROPDOWN
  813.                                                 'Select the SQL and database connection for this question
  814.                                                 strSQL = "SELECT database_sql, database_dsn " & _
  815.                                                          "FROM sur_item " & _
  816.                                                          "WHERE item_id = " & lngCurrentItemID
  817.                                                 Set rsItemDetails = conReportFilter.Execute(ConvertSQL(strSQL), , adCmdText)
  818.                                                 rsItemDetails.MoveFirst
  819.                                                 strDatabaseSQL = rsItemDetails("database_sql")
  820.                                                 strDatabaseDSN = rsItemDetails("database_dsn")
  821.                                                 rsItemDetails.Close
  822.                                                 Set rsItemDetails = Nothing
  823.  
  824.                                                 'Select all of the answers for the question
  825.                                                 On Error Resume Next
  826.                                                 conItemDetails.Open strDatabaseDSN
  827.                                                 If Err.number = 0 Then
  828.                                                     Set rsAnswers = conItemDetails.Execute(ConvertSQL(strDatabaseSQL), , adCmdText)
  829.                                                     If Err.number <> 0 Then
  830.                                                         flgAnswersExist = False
  831.                                                     End If
  832.                                                 Else
  833.                                                     flgAnswersExist = False
  834.                                                 End If
  835.                                                 On Error GoTo 0
  836. %>
  837.                                                 <select style="width:256px" name="cboAnswer<%=lngCurrentReportFilterID%>" id="cboAnswer<%=lngCurrentReportFilterID%>" onChange="javascript:answerSelected(this.value, '<% If CStr(lngAnswerID) = SUR_CONTROL_OTHER Then Response.Write "True" Else Response.Write "False" End If %>');">
  838. <%
  839.                                                     'If there are answers to display, render them
  840.                                                     If flgAnswersExist = True Then
  841.                                                         rsAnswers.MoveFirst
  842.  
  843.                                                         'Capture the answer text for the current record, to use for comparisons.  If the field is
  844.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  845.                                                         If Len(Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  846.                                                             strAnswerText = Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))
  847.                                                         Else
  848.                                                             'If there is no postback, use the first answer in the list
  849.                                                             strAnswerText = rsReportFilters("answer_text")
  850.                                                             If IsNull(strAnswerText) = True Or Len(Trim(strAnswerText)) = 0 Then
  851.                                                                 strAnswerText = rsAnswers("ItemValue")
  852.                                                             End If
  853.                                                         End If
  854.                                                         Do While Not rsAnswers.EOF
  855. %>
  856.                                                             <option <% If CStr(rsAnswers("ItemValue")) = CStr(strAnswerText) Then Response.Write "selected" End If %> value="<%=rsAnswers("ItemValue")%>"><%=rsAnswers("ItemDisplay")%></option>
  857. <%
  858.                                                             rsAnswers.MoveNext
  859.                                                         Loop
  860.                                                     End If
  861.  
  862.                                                     'Clean up
  863.                                                     If flgAnswersExist = True Then
  864.                                                         rsAnswers.Close
  865.                                                     End If
  866.                                                     Set conItemDetails = Nothing
  867. %>
  868.                                                 </select>
  869. <%
  870.                                             Case SUR_ITEM_RANKING, SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES
  871.                                                         'Select all of the subitems for the question.
  872.                                                         strSQL = "SELECT subitem_id, subitem_text " & _
  873.                                                                     "FROM sur_subitem " & _
  874.                                                                     "WHERE item_id = " & lngCurrentItemID & _
  875.                                                                     " ORDER BY order_number"
  876.                                                         rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  877.                                                         rsSubItems.MoveFirst
  878.  
  879.                                                         'Capture the answer ID for the current record, to use for comparisons.  If the field is
  880.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  881.                                                         If Len(Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))) > 0 Then
  882.                                                             lngSubItemID = Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))
  883.                                                         Else
  884.                                                             lngSubItemID = rsReportFilters("subitem_id")
  885.                                                             If Len(Trim(lngSubItemID)) = 0 Or IsNull(lngSubItemID) = True Then
  886.                                                                 lngSubItemID = rsSubItems("subitem_id")
  887.                                                             End If
  888.                                                         End If
  889. %>
  890.                                                         <select style="width:256px" name="cboSubItem<%=lngCurrentReportFilterID%>" id="cboSubItem<%=lngCurrentReportFilterID%>">
  891. <%
  892.                                                             Do While Not rsSubItems.EOF
  893. %>
  894.                                                                 <option <% If CStr(rsSubItems("subitem_id")) = CStr(lngSubItemID) Then Response.Write "selected" End If %> value="<%=rsSubItems("subitem_id")%>"><%=rsSubItems("subitem_text")%></option>
  895. <%
  896.                                                                 rsSubItems.MoveNext
  897.                                                             Loop
  898.                                                             rsSubItems.Close
  899. %>
  900.                                                         </select>
  901.                                                     </td>
  902.                                                 </tr>
  903.                                                 <tr>
  904.                                                     <td>
  905.                                                         <span class="Normal">Include records</span>
  906.                                                     </td>
  907.                                                     <td>
  908. <%
  909.                                                         If CLng(lngItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  910.                                                             'Capture the first operator for the current record, to use for comparisons.  If the field is
  911.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  912.                                                             If Len(Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))) > 0 Then
  913.                                                                 strOperatorFirst = Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))
  914.                                                             Else
  915.                                                                 strOperatorFirst = rsReportFilters("operator_first")
  916.                                                             End If
  917. %>
  918.                                                             <select style="width:125px" name="cboOperatorFirst<%=lngCurrentReportFilterID%>" id="cboOperatorFirst<%=lngCurrentReportFilterID%>">
  919.                                                                 <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%></option>
  920.                                                                 <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%></option>
  921.                                                             </select>
  922. <%
  923.                                                             'Capture the second operator for the current record, to use for comparisons.  If the field is
  924.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  925.                                                             If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  926.                                                                 strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  927.                                                             Else
  928.                                                                 strOperatorSecond = rsReportFilters("operator_second")
  929.                                                             End If
  930. %>
  931.                                                             <select style="width:125px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  932.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%></option>
  933.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%></option>
  934.                                                             </select>
  935. <%
  936.                                                         Else 'Ranking question
  937.                                                             'Capture the second operator for the current record, to use for comparisons.  If the field is
  938.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  939.                                                             If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  940.                                                                 strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  941.                                                             Else
  942.                                                                 strOperatorSecond = rsReportFilters("operator_second")
  943.                                                             End If
  944. %>
  945.                                                             <select style="width:256px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  946.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%></option>
  947.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%></option>
  948.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%></option>
  949.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%></option>
  950.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%></option>
  951.                                                             </select>
  952. <%
  953.                                                             'Capture the numeric ranking value for the current record, to use for comparisons.  If the field is
  954.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  955.                                                             If Len(Request.Form("cboRanking" & CStr(lngCurrentReportFilterID))) > 0 Then
  956.                                                                 strAnswerText = Request.Form("cboRanking" & CStr(lngCurrentReportFilterID))
  957.                                                             Else
  958.                                                                 If Len(rsReportFilters("answer_text")) = 0 Then
  959.                                                                     strAnswerText = "1"
  960.                                                                 Else
  961.                                                                     strAnswerText = rsReportFilters("answer_text")
  962.                                                                 End If
  963.                                                             End If
  964.  
  965.                                                             'Select the count of subitems for the ranking questio.
  966.                                                             strSQL = "SELECT subitem_count " & _
  967.                                                                         "FROM sur_item " & _
  968.                                                                         "WHERE item_id = " & lngCurrentItemID
  969.                                                             rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  970.                                                             rsSubItems.MoveFirst
  971.                                                             lngSubItemCount = CLng(rsSubItems("subitem_count"))
  972.                                                             rsSubItems.Close
  973. %>
  974.                                                             <select style="width:125px" name="cboRanking<%=lngCurrentReportFilterID%>" id="cboRanking<%=lngCurrentReportFilterID%>">
  975. <%
  976.                                                                 For i = 1 To lngSubItemCount
  977. %>
  978.                                                                     <option <% If CStr(i) = CStr(strAnswerText) Then Response.Write "selected" End If %> value="<%=i%>"><%=i%></option>
  979. <%
  980.                                                                 Next
  981. %>
  982.                                                             </select>
  983. <%
  984.                                                         End If
  985.                                             Case SUR_ITEM_CONSTANT_SUM
  986.                                                         'Select all of the subitems for the question.
  987.                                                         strSQL = "SELECT subitem_id, subitem_text " & _
  988.                                                                     "FROM sur_subitem " & _
  989.                                                                     "WHERE item_id = " & lngCurrentItemID & _
  990.                                                                     " ORDER BY order_number"
  991.                                                         rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  992.                                                         rsSubItems.MoveFirst
  993.  
  994.                                                         'Capture the answer ID for the current record, to use for comparisons.  If the field is
  995.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  996.                                                         If Len(Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))) > 0 Then
  997.                                                             lngSubItemID = Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))
  998.                                                         Else
  999.                                                             lngSubItemID = rsReportFilters("subitem_id")
  1000.                                                             If Len(Trim(lngSubItemID)) = 0 Or IsNull(lngSubItemID) = True Then
  1001.                                                                 lngSubItemID = rsSubItems("subitem_id")
  1002.                                                             End If
  1003.                                                         End If
  1004. %>
  1005.                                                         <select style="width:256px" name="cboSubItem<%=lngCurrentReportFilterID%>" id="cboSubItem<%=lngCurrentReportFilterID%>">
  1006. <%
  1007.                                                             Do While Not rsSubItems.EOF
  1008. %>
  1009.                                                                 <option <% If CStr(rsSubItems("subitem_id")) = CStr(lngSubItemID) Then Response.Write "selected" End If %> value="<%=rsSubItems("subitem_id")%>"><%=rsSubItems("subitem_text")%></option>
  1010. <%
  1011.                                                                 rsSubItems.MoveNext
  1012.                                                             Loop
  1013.                                                             rsSubItems.Close
  1014. %>
  1015.                                                         </select>
  1016.                                                     </td>
  1017.                                                 </tr>
  1018.                                                 <tr>
  1019.                                                     <td>
  1020.                                                         <span class="Normal">Include records</span>
  1021.                                                     </td>
  1022.                                                     <td>
  1023. <%
  1024.                                                         'Capture the second operator for the current record, to use for comparisons.  If the field is
  1025.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1026.                                                         If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  1027.                                                             strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  1028.                                                         Else
  1029.                                                             strOperatorSecond = rsReportFilters("operator_second")
  1030.                                                         End If
  1031. %>
  1032.                                                         <select style="width:256px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  1033.                                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%></option>
  1034.                                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%></option>
  1035.                                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%></option>
  1036.                                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%></option>
  1037.                                                             <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%></option>
  1038.                                                         </select>
  1039. <%
  1040.                                             Case SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS, SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES
  1041.                                                         'Select all of the subitems for the question.
  1042.                                                         strSQL = "SELECT subitem_id, subitem_text " & _
  1043.                                                                     "FROM sur_subitem " & _
  1044.                                                                     "WHERE item_id = " & lngCurrentItemID & _
  1045.                                                                     " ORDER BY order_number"
  1046.                                                         rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  1047.                                                         rsSubItems.MoveFirst
  1048.  
  1049.                                                         'Capture the subitem ID for the current record, to use for comparisons.  If the field is
  1050.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1051.                                                         If Len(Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))) > 0 Then
  1052.                                                             lngSubItemID = Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))
  1053.                                                         Else
  1054.                                                             'If there is no subitem ID in either the database or a submitted form, use
  1055.                                                             'the first subitem
  1056.                                                             lngSubItemID = rsReportFilters("subitem_id")
  1057.                                                             If IsNull(lngSubItemID) = True Or Len(Trim(lngSubItemID)) = 0 Then
  1058.                                                                 lngSubItemID = rsSubItems("subitem_id")
  1059.                                                             End If
  1060.                                                         End If
  1061. %>
  1062.                                                         <select style="width:256px" name="cboSubItem<%=lngCurrentReportFilterID%>" id="cboSubItem<%=lngCurrentReportFilterID%>">
  1063. <%
  1064.                                                             Do While Not rsSubItems.EOF
  1065. %>
  1066.                                                                 <option <% If CStr(rsSubItems("subitem_id")) = CStr(lngSubItemID) Then Response.Write "selected" End If %> value="<%=rsSubItems("subitem_id")%>"><%=rsSubItems("subitem_text")%></option>
  1067. <%
  1068.                                                                 rsSubItems.MoveNext
  1069.                                                             Loop
  1070.                                                             rsSubItems.Close
  1071. %>
  1072.                                                         </select>
  1073.                                                     </td>
  1074.                                                 </tr>
  1075.                                                 <tr>
  1076.                                                     <td>
  1077.                                                         <span class="Normal">Select answer</span>
  1078.                                                     </td>
  1079.                                                     <td>
  1080. <%
  1081.                                                         'Select all of the answers for the question.
  1082.                                                         strSQL = "SELECT answer_id, answer_text " & _
  1083.                                                                     "FROM sur_item_answer " & _
  1084.                                                                     "WHERE item_id = " & lngCurrentItemID & _
  1085.                                                                     " ORDER BY order_number"
  1086.                                                         rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  1087.                                                         rsAnswers.MoveFirst
  1088.  
  1089.                                                         'Capture the answer ID for the current record, to use for comparisons.  If the field is
  1090.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1091.                                                         If Len(Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  1092.                                                             lngAnswerID = Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))
  1093.                                                         Else
  1094.                                                             'If there is no answer ID in either the database or a submitted form, use
  1095.                                                             'the first answer
  1096.                                                             lngAnswerID = rsReportFilters("answer_id")
  1097.                                                             If IsNull(lngAnswerID) = True Or Len(Trim(lngAnswerID)) = 0 Then
  1098.                                                                 lngAnswerID = rsAnswers("answer_id")
  1099.                                                             End If
  1100.                                                         End If
  1101.  
  1102. %>
  1103.                                                         <select style="width:256px" name="cboAnswer<%=lngCurrentReportFilterID%>" id="cboAnswer<%=lngCurrentReportFilterID%>">
  1104. <%
  1105.                                                             Do While Not rsAnswers.EOF
  1106. %>
  1107.                                                                 <option <% If CStr(rsAnswers("answer_id")) = CStr(lngAnswerID) Then Response.Write "SELECTED" End If %> value="<%=rsAnswers("answer_id")%>"><%=rsAnswers("answer_text")%></option>
  1108. <%
  1109.                                                                 rsAnswers.MoveNext
  1110.                                                             Loop
  1111.                                                             rsAnswers.Close
  1112. %>
  1113.                                                         </select>
  1114. <%
  1115.                                             Case SUR_ITEM_MATRIX_RATING_SCALE
  1116.                                                         'Capture the subitem ID for the current record, to use for comparisons.  If the field is
  1117.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1118.                                                         If Len(Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))) > 0 Then
  1119.                                                             lngSubItemID = Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))
  1120.                                                         Else
  1121.                                                             'If there is no subitem ID in either the database or a submitted form, use
  1122.                                                             'the first subitem
  1123.                                                             lngSubItemID = rsReportFilters("subitem_id")
  1124.                                                             If IsNull(lngSubItemID) = True Or Len(Trim(lngSubItemID)) = 0 Then
  1125.                                                                 lngSubItemID = rsAnswers("subitem_id")
  1126.                                                             End If
  1127.                                                         End If
  1128.  
  1129.                                                         'Select all of the subitems for the question.
  1130.                                                         strSQL = "SELECT subitem_id, subitem_text " & _
  1131.                                                                     "FROM sur_subitem " & _
  1132.                                                                     "WHERE item_id = " & lngCurrentItemID & _
  1133.                                                                     " ORDER BY order_number"
  1134.                                                         rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  1135.                                                         rsSubItems.MoveFirst
  1136. %>
  1137.                                                         <select style="width:256px" name="cboSubItem<%=lngCurrentReportFilterID%>" id="cboSubItem<%=lngCurrentReportFilterID%>">
  1138. <%
  1139.                                                             Do While Not rsSubItems.EOF
  1140. %>
  1141.                                                                 <option <% If CStr(rsSubItems("subitem_id")) = CStr(lngSubItemID) Then Response.Write "selected" End If %> value="<%=rsSubItems("subitem_id")%>"><%=rsSubItems("subitem_text")%></option>
  1142. <%
  1143.                                                                 rsSubItems.MoveNext
  1144.                                                             Loop
  1145.                                                             rsSubItems.Close
  1146. %>
  1147.                                                         </select>
  1148.                                                     </td>
  1149.                                                 </tr>
  1150.                                                 <tr>
  1151.                                                     <td>
  1152.                                                         <span class="Normal">Include records</span>
  1153.                                                     </td>
  1154.                                                     <td>
  1155. <%
  1156.                                                         If CLng(lngItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  1157.                                                             'Capture the first operator for the current record, to use for comparisons.  If the field is
  1158.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1159.                                                             If Len(Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))) > 0 Then
  1160.                                                                 strOperatorFirst = Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))
  1161.                                                             Else
  1162.                                                                 strOperatorFirst = rsReportFilters("operator_first")
  1163.                                                             End If
  1164. %>
  1165.                                                             <select style="width:125px" name="cboOperatorFirst<%=lngCurrentReportFilterID%>" id="cboOperatorFirst<%=lngCurrentReportFilterID%>">
  1166.                                                                 <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%></option>
  1167.                                                                 <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%></option>
  1168.                                                             </select>
  1169. <%
  1170.                                                             'Capture the second operator for the current record, to use for comparisons.  If the field is
  1171.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1172.                                                             If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  1173.                                                                 strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  1174.                                                             Else
  1175.                                                                 strOperatorSecond = rsReportFilters("operator_second")
  1176.                                                             End If
  1177. %>
  1178.                                                             <select style="width:125px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  1179.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%></option>
  1180.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%></option>
  1181.                                                             </select>
  1182. <%
  1183.                                                         Else 'Ranking question
  1184.                                                             'Capture the second operator for the current record, to use for comparisons.  If the field is
  1185.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1186.                                                             If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  1187.                                                                 strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  1188.                                                             Else
  1189.                                                                 strOperatorSecond = rsReportFilters("operator_second")
  1190.                                                             End If
  1191.  
  1192.                                                             If CLng(lngItemTypeID) = SUR_ITEM_CONSTANT_SUM Then
  1193.                                                                 strOperatorPrefix = "where sum is "
  1194.                                                             ElseIf CLng(lngItemTypeID) = SUR_ITEM_DATE Or CLng(lngItemTypeID) = SUR_ITEM_NUMBER Then
  1195.                                                                 strOperatorPrefix = "that are "
  1196.                                                             Else
  1197.                                                                 strOperatorPrefix = ""
  1198.                                                             End If
  1199. %>
  1200.                                                             <select style="width:256px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  1201.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER%></option>
  1202.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_GREATER_EQUAL%></option>
  1203.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_EQUAL%></option>
  1204.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_LESS%></option>
  1205.                                                                 <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%>"><%=strOperatorPrefix & SUR_REPORT_FILTER_OPERATOR_SECOND_LESS_EQUAL%></option>
  1206.                                                             </select>
  1207. <%
  1208.                                                             'Capture the numeric ranking value for the current record, to use for comparisons.  If the field is
  1209.                                                             'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1210.                                                             If Len(Request.Form("cboRanking" & CStr(lngCurrentReportFilterID))) > 0 Then
  1211.                                                                 strAnswerText = Request.Form("cboRanking" & CStr(lngCurrentReportFilterID))
  1212.                                                             Else
  1213.                                                                 If Len(rsReportFilters("answer_text")) = 0 Then
  1214.                                                                     strAnswerText = "1"
  1215.                                                                 Else
  1216.                                                                     strAnswerText = rsReportFilters("answer_text")
  1217.                                                                 End If
  1218.                                                             End If
  1219.  
  1220.                                                             'Select the count of subitems for the ranking questio.
  1221.                                                             strSQL = "SELECT minimum_value, maximum_value " & _
  1222.                                                                         "FROM sur_item " & _
  1223.                                                                         "WHERE item_id = " & lngCurrentItemID
  1224.                                                             rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  1225.                                                             rsSubItems.MoveFirst
  1226.                                                             lngMinimumValue = rsSubItems("minimum_value")
  1227.                                                             lngMaximumValue = rsSubItems("maximum_value")
  1228.                                                             rsSubItems.Close
  1229. %>
  1230.                                                             <select style="width:125px" name="cboRanking<%=lngCurrentReportFilterID%>" id="cboRanking<%=lngCurrentReportFilterID%>">
  1231. <%
  1232.                                                                 For i = lngMinimumValue To lngMaximumValue
  1233. %>
  1234.                                                                     <option <% If CStr(i) = CStr(strAnswerText) Then Response.Write "selected" End If %> value="<%=i%>"><%=i%></option>
  1235. <%
  1236.                                                                 Next
  1237. %>
  1238.                                                             </select>
  1239. <%
  1240.                                                         End If
  1241.                                             Case SUR_ITEM_MATRIX_TEXT_BOXES
  1242.                                                         'Select all of the subitems for the question.
  1243.                                                         strSQL = "SELECT subitem_id, subitem_text " & _
  1244.                                                                     "FROM sur_subitem " & _
  1245.                                                                     "WHERE item_id = " & lngCurrentItemID & _
  1246.                                                                     " ORDER BY order_number"
  1247.                                                         rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  1248.                                                         rsSubItems.MoveFirst
  1249.  
  1250.                                                         'Capture the subitem ID for the current record, to use for comparisons.  If the field is
  1251.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1252.                                                         If Len(Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))) > 0 Then
  1253.                                                             lngSubItemID = Request.Form("cboSubItem" & CStr(lngCurrentReportFilterID))
  1254.                                                         Else
  1255.                                                             'If there is no subitem ID in either the database or a submitted form, use
  1256.                                                             'the first subitem
  1257.                                                             lngSubItemID = rsReportFilters("subitem_id")
  1258.                                                             If IsNull(lngSubItemID) = True Or Len(Trim(lngSubItemID)) = 0 Then
  1259.                                                                 lngSubItemID = rsSubItems("subitem_id")
  1260.                                                             End If
  1261.                                                         End If
  1262. %>
  1263.                                                         <select style="width:256px" name="cboSubItem<%=lngCurrentReportFilterID%>" id="cboSubItem<%=lngCurrentReportFilterID%>">
  1264. <%
  1265.                                                             Do While Not rsSubItems.EOF
  1266. %>
  1267.                                                                 <option <% If CStr(rsSubItems("subitem_id")) = CStr(lngSubItemID) Then Response.Write "selected" End If %> value="<%=rsSubItems("subitem_id")%>"><%=rsSubItems("subitem_text")%></option>
  1268. <%
  1269.                                                                 rsSubItems.MoveNext
  1270.                                                             Loop
  1271.                                                             rsSubItems.Close
  1272. %>
  1273.                                                         </select>
  1274.                                                     </td>
  1275.                                                 </tr>
  1276.                                                 <tr>
  1277.                                                     <td>
  1278.                                                         <span class="Normal">Select column</span>
  1279.                                                     </td>
  1280.                                                     <td>
  1281. <%
  1282.                                                         'Select all of the answers for the question.
  1283.                                                         strSQL = "SELECT answer_id, answer_text " & _
  1284.                                                                     "FROM sur_item_answer " & _
  1285.                                                                     "WHERE item_id = " & lngCurrentItemID & _
  1286.                                                                     " ORDER BY order_number"
  1287.                                                         rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  1288.                                                         rsAnswers.MoveFirst
  1289.  
  1290.                                                         'Capture the answer ID for the current record, to use for comparisons.  If the field is
  1291.                                                         'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1292.                                                         If Len(Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  1293.                                                             lngAnswerID = Request.Form("cboAnswer" & CStr(lngCurrentReportFilterID))
  1294.                                                         Else
  1295.                                                             'If there is no answer ID in either the database or a submitted form, use
  1296.                                                             'the first subitem
  1297.                                                             lngAnswerID = rsReportFilters("answer_id")
  1298.                                                             If IsNull(lngAnswerID) = True Or Len(Trim(lngAnswerID)) = 0 Then
  1299.                                                                 lngAnswerID = rsAnswers("answer_id")
  1300.                                                             End If
  1301.                                                         End If
  1302. %>
  1303.                                                         <select style="width:256px" name="cboAnswer<%=lngCurrentReportFilterID%>" id="cboAnswer<%=lngCurrentReportFilterID%>">
  1304. <%
  1305.                                                             Do While Not rsAnswers.EOF
  1306. %>
  1307.                                                                 <option <% If CStr(rsAnswers("answer_id")) = CStr(lngAnswerID) Then Response.Write "SELECTED" End If %> value="<%=rsAnswers("answer_id")%>"><%=rsAnswers("answer_text")%></option>
  1308. <%
  1309.                                                                 rsAnswers.MoveNext
  1310.                                                             Loop
  1311.                                                             rsAnswers.Close
  1312. %>
  1313.                                                         </select>
  1314.                                                     </td>
  1315.                                                 </tr>
  1316.                                                 <tr>
  1317.                                                     <td>
  1318.                                                         <span class="Normal">Include records</span>
  1319.                                                     </td>
  1320.                                                     <td>
  1321. <%
  1322.                                                 'Capture the first operator for the current record, to use for comparisons.  If the field is
  1323.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1324.                                                 If Len(Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))) > 0 Then
  1325.                                                     strOperatorFirst = Request.Form("cboOperatorFirst" & CStr(lngCurrentReportFilterID))
  1326.                                                 Else
  1327.                                                     strOperatorFirst = rsReportFilters("operator_first")
  1328.                                                 End If
  1329. %>
  1330.                                                 <select style="width:125px" name="cboOperatorFirst<%=lngCurrentReportFilterID%>" id="cboOperatorFirst<%=lngCurrentReportFilterID%>">
  1331.                                                     <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT%></option>
  1332.                                                     <option <% If strOperatorFirst = SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%>"><%=SUR_REPORT_FILTER_OPERATOR_FIRST_THAT_DO_NOT%></option>
  1333.                                                 </select>
  1334. <%
  1335.                                                 'Capture the second operator for the current record, to use for comparisons.  If the field is
  1336.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1337.                                                 If Len(Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))) > 0 Then
  1338.                                                     strOperatorSecond = Request.Form("cboOperatorSecond" & CStr(lngCurrentReportFilterID))
  1339.                                                 Else
  1340.                                                     strOperatorSecond = rsReportFilters("operator_second")
  1341.                                                 End If
  1342. %>
  1343.                                                 <select style="width:125px" name="cboOperatorSecond<%=lngCurrentReportFilterID%>" id="cboOperatorSecond<%=lngCurrentReportFilterID%>">
  1344.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_CONTAIN%></option>
  1345.                                                     <option <% If strOperatorSecond = SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH Then Response.Write "selected" End If %> value="<%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%>"><%=SUR_REPORT_FILTER_OPERATOR_SECOND_MATCH%></option>
  1346.                                                 </select>
  1347. <%
  1348.                                         End Select
  1349.  
  1350.                                         'Display a text box for entering open-ended values
  1351.                                         If CLng(lngItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Or CLng(lngItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Or CLng(lngItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_LINE Or CLng(lngItemTypeID) = SUR_ITEM_OPEN_ENDED_COMMENTS_BOX Or CLng(lngItemTypeID) = SUR_ITEM_DATE Or CLng(lngItemTypeID) = SUR_ITEM_NUMBER Or CLng(lngItemTypeID) = SUR_ITEM_CONSTANT_SUM Or (lngAnswerID = SUR_CONTROL_OTHER And CLng(lngItemTypeID) <> SUR_ITEM_SINGLE_SELECT_DROPDOWN)Then
  1352.                                             'For numbers and dates, make sure that the data is in a valid format
  1353.                                             If CLng(lngItemTypeID) = SUR_ITEM_DATE Then
  1354.                                                 'Capture the answer text for the current record, to use for comparisons.  If the field is
  1355.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1356.                                                 If Len(Request.Form("txtAnswerDate" & CStr(lngCurrentReportFilterID))) > 0 Then
  1357.                                                     strAnswerText = Request.Form("txtAnswerDate" & CStr(lngCurrentReportFilterID))
  1358.                                                 Else
  1359.                                                     strAnswerText = rsReportFilters("answer_text")
  1360.                                                 End If
  1361.  
  1362.                                                 If IsDate(strAnswerText) = False Then
  1363.                                                     strAnswerText = ""
  1364.                                                 End If
  1365.                                             ElseIf CLng(lngItemTypeID) = SUR_ITEM_NUMBER Or CLng(lngItemTypeID) = SUR_ITEM_CONSTANT_SUM Then
  1366.                                                 'Capture the answer text for the current record, to use for comparisons.  If the field is
  1367.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1368.                                                 If Len(Request.Form("txtAnswerNumber" & CStr(lngCurrentReportFilterID))) > 0 Then
  1369.                                                     strAnswerText = Request.Form("txtAnswerNumber" & CStr(lngCurrentReportFilterID))
  1370.                                                 Else
  1371.                                                     strAnswerText = rsReportFilters("answer_text")
  1372.                                                 End If
  1373.  
  1374.                                                 If IsNumeric(strAnswerText) = False Then
  1375.                                                     strAnswerText = ""
  1376.                                                 End If
  1377.                                             Else
  1378.                                                 'Capture the answer text for the current record, to use for comparisons.  If the field is
  1379.                                                 'in the form due to a postback, use the form field.  Otherwise, use the field from the database.
  1380.                                                 If Len(Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))) > 0 Then
  1381.                                                     strAnswerText = Request.Form("txtAnswer" & CStr(lngCurrentReportFilterID))
  1382.                                                 Else
  1383.                                                     strAnswerText = rsReportFilters("answer_text")
  1384.                                                 End If
  1385.                                             End If
  1386.  
  1387.                                             'Set the name of the input control based on the type of question. The different names are needed
  1388.                                             'for the client-side JavaScript.
  1389.                                             If CLng(lngItemTypeID) = SUR_ITEM_DATE Then
  1390.                                                 strAnswerControlName = "txtAnswerDate"
  1391.                                             ElseIf CLng(lngItemTypeID) = SUR_ITEM_NUMBER Or CLng(lngItemTypeID) = SUR_ITEM_CONSTANT_SUM Then
  1392.                                                 strAnswerControlName = "txtAnswerNumber"
  1393.                                             Else
  1394.                                                 strAnswerControlName = "txtAnswer"
  1395.                                             End If
  1396. %>
  1397.                                             <input value="<%=strAnswerText%>" type="text" style="width:135px" name="<%=strAnswerControlName%><%=lngCurrentReportFilterID%>" maxlength="50">
  1398. <%
  1399.                                         End If
  1400. %>
  1401.                                     </td>
  1402.                                 </tr>
  1403. <%
  1404.                             Else
  1405.                                 'Additional filter types should go here...
  1406.                             End If
  1407. %>
  1408.                         </table>
  1409.                     </td>
  1410.                 </tr>
  1411. <%
  1412.                 'Alternate the colors for the rows in the table
  1413.                 If strTableRowColor = "TableRowDarkColor" Then
  1414.                     strTableRowColor = "TableRowLightColor"
  1415.                 Else
  1416.                     strTableRowColor = "TableRowDarkColor"
  1417.                 End If
  1418.  
  1419.                 rsReportFilters.MoveNext
  1420.                 lngCurrentFilterNumber = lngCurrentFilterNumber + 1
  1421.             Loop
  1422.         End If
  1423.  
  1424.         'Clean up
  1425.         rsReportFilters.Close
  1426.         Set rsReportFilters = Nothing
  1427. %>
  1428.         <tr class="WhiteBackgroundColor">
  1429.             <td align="right" colspan="4">
  1430.                 <a href="javascript:insertFilter();"><img border="0" alt="Insert a new report filter" name="btnInsertFilter" src="Resources/Buttons/InsertFilter.gif"></a>
  1431.                 <a href="ResultsOverview.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&SurveyID=<%=lngSurveyID%>"><img border="0" alt="View summary results for this survey" name="btnResultsOverview" src="Resources/Buttons/ResultsOverview.gif"></a>
  1432. <%
  1433.                 If lngReportFilterCount > 0 Then
  1434. %>
  1435.                     <a href="javascript:submitCheck();"><img border="0" alt="Save all report filters" name="btnSave" src="Resources/Buttons/Save.gif"></a> 
  1436. <%
  1437.                 End If
  1438. %>
  1439.             </td>
  1440.         </tr>
  1441.     </form>
  1442. </table>
  1443.  
  1444. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  1445.  
  1446. </body>
  1447. </html>
  1448.  
  1449. <%
  1450.     'Clean up
  1451.     rsQuestions.Close
  1452.     Set rsQuestions = Nothing
  1453.     rsHiddenFields.Close
  1454.     Set rsHiddenFields = Nothing
  1455.  
  1456.     'Ensure that the web server returns the page
  1457.     Response.Flush
  1458. %>
  1459.