home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / Item.asp < prev    next >
Text File  |  2006-10-25  |  91KB  |  1,920 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.11
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page allows the user to create a new item or
  7. '                     to edit an existing one.
  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/Config_inc.asp"-->
  17. <!--#Include File="Include/Constants_inc.asp"-->
  18. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  19. <!--#Include File="Include/Utility_inc.asp"-->
  20. <!--#Include File="Include/adovbs_inc.asp"-->
  21. <!--#Include File="Include/CurrentUser_inc.asp"-->
  22. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  23. <html>
  24. <head>
  25.     <title>Insert Item</title>
  26.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  27. </head>
  28.  
  29. <%
  30.     Dim strPageHeading
  31.     Dim strWizardHeading
  32.     Dim strSQL
  33.     Dim conItem
  34.     Dim rsItemTypes
  35.     Dim rsItems
  36.     Dim strItemTypes
  37.     Dim lngSurveyID
  38.     Dim lngLibraryID
  39.     Dim strSurveyName
  40.     Dim strLibraryName
  41.     Dim lngItemID
  42.     Dim strState
  43.     Dim lngComboItemTypeID
  44.     Dim lngSurveyOrLibraryID
  45.     Dim lngPersistedItemTypeID
  46.     Dim lngAnswerCount
  47.     Dim i
  48.     Dim lngRows
  49.     Dim strItemText
  50.     Dim strDefaultValue
  51.     Dim strDisplayFormat
  52.     Dim strOtherDisplayType
  53.     Dim strItemSubText
  54.     Dim strItemAlias
  55.     Dim strMinimumValue
  56.     Dim strMaximumValue
  57.     Dim strMinimumNumberResponses
  58.     Dim strMaximumLength
  59.     Dim strAnswerTotal
  60.     Dim strMaximumNumberResponses
  61.     Dim strRowTextWidth
  62.     Dim strRequiredYesNo
  63.     Dim strRandomOrderYesNo
  64.     Dim strEmailAddressYesNo
  65.     Dim strOtherYesNo
  66.     Dim strOtherText
  67.     Dim rsAnswers
  68.     Dim lngPreviousAnswerCount
  69.     Dim strValue
  70.     Dim strAnswerValue
  71.     Dim strChecked
  72.     Dim strDefaultYN
  73.     Dim strImageHeight
  74.     Dim strImageWidth
  75.     Dim strImagePath
  76.     Dim strImageAlignment
  77.     Dim lngPageNumber
  78.     Dim rsSubItems
  79.     Dim strRowNames
  80.     Dim flgHasResponses
  81.     Dim strDatabaseDSN
  82.     Dim strDatabaseSQL
  83.     Dim rsAnswerGroups
  84.  
  85.     'Initialization
  86.     Set conItem = Server.CreateObject("ADODB.Connection")
  87.     Set rsAnswers = Server.CreateObject("ADODB.Recordset")
  88.     Set rsAnswerGroups = Server.CreateObject("ADODB.Recordset")
  89.     Set rsSubItems = Server.CreateObject("ADODB.Recordset")
  90.     conItem.Open SURVEY_APP_CONNECTION
  91.     strItemTypes = "<option value=""" & SUR_COMBO_PLEASE_SELECT & """>" & SUR_COMBO_PLEASE_SELECT & "</option>"
  92.     lngComboItemTypeID = Request.Form("cboItemType")
  93.  
  94.     'Check to see if this is an item for a library or a survey
  95.     If Len(Request.Form("SurveyID")) > 0 Then
  96.         lngSurveyID = Request.Form("SurveyID")
  97.         lngSurveyOrLibraryID = lngSurveyID
  98.         strSurveyName = Request.Form("SurveyName")
  99.         flgHasResponses = HasResponses(lngSurveyID)
  100.     Else 'Library
  101.         flgHasResponses = False
  102.         lngSurveyOrLibraryID = lngLibraryID
  103.         lngLibraryID = Request.Form("LibraryID")
  104.         strLibraryName = Request.Form("LibraryName")
  105.     End If
  106.     lngItemID = Request.Form("ItemID")
  107.     lngPageNumber = Request.Form("PageNumber")
  108.     strState = Request.Form("State")
  109.  
  110.     'Do not allow a user to add a new item to a survey that already has responses.  Instead, redirect the user back
  111.     'to the modify survey page
  112.     If strState = SUR_STATE_INSERT And flgHasResponses = True Then
  113.         Response.Redirect "ModifySurvey.asp?SurveyID=" & lngSurveyID
  114.     End If
  115.  
  116.     Select Case strState
  117.         Case SUR_STATE_INSERT 'When the user first arrives at this screen to CREATE a new item
  118.             strPageHeading = "Insert Item"
  119.             strWizardHeading = "Create New Item"
  120.             strOtherText = "Other, please specify"
  121.             'For matrix rating scales, specify defaults for the minimum and maximum values for the rating scale
  122.             If CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Then
  123.                 strMinimumValue = SUR_DEFAULT_MINIMUM_RANKING_VALUE
  124.                 strMaximumValue = SUR_DEFAULT_MAXIMUM_RANKING_VALUE
  125.             End If
  126.         Case SUR_STATE_EDIT 'When the user first arrives at this screen to MODIFY a new item
  127.             strPageHeading = "Modify Item"
  128.             strWizardHeading = "Modify Existing Item"
  129.  
  130.             'Get the values in the database for the item
  131.             strSQL = "SELECT item_type_id, minimum_value, maximum_value, maximum_length, other_display_type, " & _
  132.                         "answer_total, minimum_number_responses, row_text_width, maximum_number_responses, required_yn, " & _
  133.                         "random_answer_order_yn, email_address_yn, database_dsn, other_yn, display_format, " & _
  134.                         "image_path, image_width, image_height, image_alignment, default_value, database_sql, " & _
  135.                         "item_text, item_sub_text, item_alias, other_text " & _
  136.                         "FROM sur_item WHERE item_id = " & lngItemID
  137.             Set rsItems = conItem.Execute(ConvertSQL(strSQL), , adCmdText)
  138.             rsItems.MoveFirst
  139.  
  140.             lngPersistedItemTypeID = rsItems("item_type_id")
  141.             lngComboItemTypeID = lngPersistedItemTypeID
  142.             strDatabaseSQL = rsItems("database_sql")
  143.             strItemText = rsItems("item_text")
  144.             strItemSubText = rsItems("item_sub_text")
  145.             strItemAlias = rsItems("item_alias")
  146.             strDefaultValue = rsItems("default_value")
  147.             strDisplayFormat = rsItems("display_format")
  148.             strOtherDisplayType = rsItems("other_display_type")
  149.             If Len(strOtherDisplayType) = 0 Or IsNull(strOtherDisplayType) = True Then
  150.                 strOtherDisplayType = SUR_OTHER_DISPLAY_TYPE_TEXTBOX
  151.             End If
  152.             strMinimumValue = rsItems("minimum_value")
  153.             strMaximumLength = rsItems("maximum_length")
  154.             strMaximumValue = rsItems("maximum_value")
  155.             strAnswerTotal = rsItems("answer_total")
  156.             strMinimumNumberResponses = rsItems("minimum_number_responses")
  157.             strMaximumNumberResponses = rsItems("maximum_number_responses")
  158.             strRowTextWidth = rsItems("row_text_width")
  159.             strDatabaseDSN = rsItems("database_dsn")
  160.             strRequiredYesNo = rsItems("required_yn")
  161.             strRandomOrderYesNo = rsItems("random_answer_order_yn")
  162.             strEmailAddressYesNo = rsItems("email_address_yn")
  163.             strOtherText = rsItems("other_text")
  164.             strOtherYesNo = rsItems("other_yn")
  165.             strImagePath = rsItems("image_path")
  166.             strImageWidth = rsItems("image_width")
  167.             strImageHeight = rsItems("image_height")
  168.             strImageAlignment = rsItems("image_alignment")
  169.             strDatabaseDSN = rsItems("database_dsn")
  170.             rsItems.Close
  171.             Set rsItems = Nothing
  172.         Case SUR_STATE_EDIT_REFRESH 'Already in EDIT mode, and the user changes the item type
  173.             strPageHeading = "Modify Item"
  174.             strWizardHeading = "Modify Existing Item"
  175.  
  176.             'Re-display answers from form
  177.             strItemText = Request.Form("txtItemText")
  178.             strItemSubText = Request.Form("txtItemSubText")
  179.             strItemAlias = Request.Form("txtItemAlias")
  180.             strDefaultValue = Request.Form("txtDefaultValue")
  181.             strDisplayFormat = Request.Form("cboDisplayType")
  182.             strOtherDisplayType = Request.Form("cboOtherDisplayType")
  183.             If Len(strOtherDisplayType) = 0 Or IsNull(strOtherDisplayType) = True Then
  184.                 strOtherDisplayType = SUR_OTHER_DISPLAY_TYPE_TEXTBOX
  185.             End If
  186.  
  187.             'For matrix rating questions, if there is no value for the minimum and maximum, set one by default
  188.             If Len(Request.Form("txtMinimumValue")) = 0 And CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Then
  189.                 strMinimumValue = SUR_DEFAULT_MINIMUM_RANKING_VALUE
  190.             Else
  191.                 strMinimumValue = Request.Form("txtMinimumValue")
  192.             End If
  193.             If Len(Request.Form("txtMaximumValue")) = 0 And CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Then
  194.                 strMaximumValue = SUR_DEFAULT_MAXIMUM_RANKING_VALUE
  195.             Else
  196.                 strMaximumValue = Request.Form("txtMaximumValue")
  197.             End If
  198.             strAnswerTotal = Request.Form("txtAnswerTotal")
  199.             strMinimumNumberResponses = Request.Form("txtMinimumNumberResponses")
  200.             strMaximumNumberResponses = Request.Form("txtMaximumNumberResponses")
  201.             strRowTextWidth = Request.Form("txtRowTextWidth")
  202.             strMaximumLength = Request.Form("txtMaximumLength")
  203.             If Request.Form("chkRequired") = "on" Then
  204.                 strRequiredYesNo = SUR_BOOLEAN_POSITIVE
  205.             Else
  206.                 strRequiredYesNo = SUR_BOOLEAN_NEGATIVE
  207.             End If
  208.             If Request.Form("chkRandomOrder") = "on" Then
  209.                 strRandomOrderYesNo = SUR_BOOLEAN_POSITIVE
  210.             Else
  211.                 strRandomOrderYesNo = SUR_BOOLEAN_NEGATIVE
  212.             End If
  213.             If Request.Form("chkEmailAddress") = "on" Then
  214.                 strEmailAddressYesNo = SUR_BOOLEAN_POSITIVE
  215.             Else
  216.                 strEmailAddressYesNo = SUR_BOOLEAN_NEGATIVE
  217.             End If
  218.  
  219.             If Request.Form("chkOther") = "on" Then
  220.                 strOtherYesNo = SUR_BOOLEAN_POSITIVE
  221.             Else
  222.                 strOtherYesNo = SUR_BOOLEAN_NEGATIVE
  223.             End If
  224.             If Len(Request.Form("txtOther")) = 0 Then
  225.                 strOtherText = "Other, please specify"
  226.             Else
  227.                 strOtherText = Request.Form("txtOther")
  228.             End If
  229.             strImagePath = Request.Form("txtImagePath")
  230.             strImageWidth = Request.Form("txtImageWidth")
  231.             strImageHeight = Request.Form("txtImageHeight")
  232.             strImageAlignment = Request.Form("cboImageAlignment")
  233.             strDatabaseSQL = Request.Form("txtDatabaseSQL")
  234.             strDatabaseDSN = Request.Form("txtDatabaseDSN")
  235.             strRowNames = Request.Form("txtRowNames")
  236.         Case SUR_STATE_INSERT_REFRESH 'Already in INSERT mode, and the user changes the item type
  237.             strPageHeading = "Insert Item"
  238.             strWizardHeading = "Create New Item"
  239.             strOtherText = "Other, please specify"
  240.  
  241.             'Re-display answers from form
  242.             strItemText = Request.Form("txtItemText")
  243.             strItemSubText = Request.Form("txtItemSubText")
  244.             strItemAlias = Request.Form("txtItemAlias")
  245.             strDefaultValue = Request.Form("txtDefaultValue")
  246.             strMaximumLength = Request.Form("txtMaximumLength")
  247.             strOtherDisplayType = Request.Form("cboOtherDisplayType")
  248.             If Len(strOtherDisplayType) = 0 Or IsNull(strOtherDisplayType) = True Then
  249.                 strOtherDisplayType = SUR_OTHER_DISPLAY_TYPE_TEXTBOX
  250.             End If
  251.  
  252.             'Use horizontal alignment as the default
  253.             If Len(Request.Form("cboDisplayType")) = 0 Then
  254.                 strDisplayFormat = SUR_ANSWER_ALIGNMENT_VERTICAL
  255.             Else
  256.                 strDisplayFormat = Request.Form("cboDisplayType")
  257.             End If
  258.  
  259.             'For matrix rating scales, specify defaults for the minimum value for the rating scale
  260.             If Len(Request.Form("txtMinimumValue")) = 0 And CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Then
  261.                 strMinimumValue = SUR_DEFAULT_MINIMUM_RANKING_VALUE
  262.             Else
  263.                 strMinimumValue = Request.Form("txtMinimumValue")
  264.             End If
  265.  
  266.             'For matrix rating scales, specify defaults for the maximum value for the rating scale
  267.             If Len(Request.Form("txtMaximumValue")) = 0 And CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Then
  268.                 strMaximumValue = SUR_DEFAULT_MAXIMUM_RANKING_VALUE
  269.             Else
  270.                 strMaximumValue = Request.Form("txtMaximumValue")
  271.             End If
  272.             strAnswerTotal = Request.Form("txtAnswerTotal")
  273.             strMinimumNumberResponses = Request.Form("txtMinimumNumberResponses")
  274.             strMaximumNumberResponses = Request.Form("txtMaximumNumberResponses")
  275.             strRowTextWidth = Request.Form("txtRowTextWidth")
  276.             If Request.Form("chkRequired") = "on" Then
  277.                 strRequiredYesNo = SUR_BOOLEAN_POSITIVE
  278.             Else
  279.                 strRequiredYesNo = SUR_BOOLEAN_NEGATIVE
  280.             End If
  281.             If Request.Form("chkRandomOrder") = "on" Then
  282.                 strRandomOrderYesNo = SUR_BOOLEAN_POSITIVE
  283.             Else
  284.                 strRandomOrderYesNo = SUR_BOOLEAN_NEGATIVE
  285.             End If
  286.             If Request.Form("chkEmailAddress") = "on" Then
  287.                 strEmailAddressYesNo = SUR_BOOLEAN_POSITIVE
  288.             Else
  289.                 strEmailAddressYesNo = SUR_BOOLEAN_NEGATIVE
  290.             End If
  291.  
  292.             If Request.Form("chkOther") = "on" Then
  293.                 strOtherYesNo = SUR_BOOLEAN_POSITIVE
  294.             Else
  295.                 strOtherYesNo = SUR_BOOLEAN_NEGATIVE
  296.             End If
  297.             If Len(Request.Form("txtOther")) = 0 Then
  298.                 strOtherText = "Other, please specify"
  299.             Else
  300.                 strOtherText = Request.Form("txtOther")
  301.             End If
  302.             strImagePath = Request.Form("txtImagePath")
  303.             strImageWidth = Request.Form("txtImageWidth")
  304.             strImageHeight = Request.Form("txtImageHeight")
  305.             strImageAlignment = Request.Form("cboImageAlignment")
  306.             strDatabaseSQL = Request.Form("txtDatabaseSQL")
  307.             strDatabaseDSN = Request.Form("txtDatabaseDSN")
  308.             strRowNames = Request.Form("txtRowNames")
  309.     End Select
  310.  
  311.     'Get the list of Item Types
  312.     strSQL = "SELECT item_type_id, item_type_name FROM sur_item_type ORDER BY item_type_name"
  313.     Set rsItemTypes = conItem.Execute(ConvertSQL(strSQL), , adCmdText)
  314.     rsItemTypes.MoveFirst
  315.  
  316.     Do While Not rsItemTypes.EOF
  317.         strItemTypes = strItemTypes & "<option "
  318.         If CLng(lngComboItemTypeID) = rsItemTypes("item_type_id") Then
  319.             strItemTypes = strItemTypes & "SELECTED "
  320.         End If
  321.         strItemTypes = strItemTypes & "value=""" & rsItemTypes("item_type_id") & """>" & rsItemTypes("item_type_name") & "</option>"
  322.         rsItemTypes.MoveNext
  323.     Loop
  324.     rsItemTypes.Close
  325.     Set rsItemTypes = Nothing
  326. %>
  327. <script language ="JavaScript" src="ClientInclude/Utility.js"></script>
  328. <script language="JavaScript">
  329. <%
  330.     If strState = SUR_STATE_INSERT Or strState = SUR_STATE_INSERT_REFRESH Then
  331. %>
  332.         function copyExistingItem()
  333.         {
  334.             document.forms['frmCopyExistingItem'].submit();
  335.         }
  336.  
  337.         function insertFromLibrary()
  338.         {
  339.             document.forms['frmCopyExistingItem'].action = 'InsertFromLibrary.asp';
  340.             document.forms['frmCopyExistingItem'].submit();
  341.         }
  342. <%
  343.     End If
  344.  
  345.     'These client-side functions are only needed if the survey does not have any responses
  346.     If flgHasResponses = False Then
  347. %>
  348.         function deleteItem(strItemID, strSurveyID, strPageNumber)
  349.         {
  350.             if (confirm("Are you sure you want to delete this item?") == true) //OK
  351.             {
  352.                 window.location.href = 'DeleteItem.asp?ItemID=' + strItemID + '&SurveyID=' + strSurveyID + '&PageNumber=' + strPageNumber;
  353.             }
  354.         }
  355.  
  356.         function itemTypeSelected()
  357.         {
  358.             if (document.forms['frmItemType'].cboItemType.value != '<%=SUR_COMBO_PLEASE_SELECT%>')
  359.             {
  360.                 if (document.forms['frmItemType'].State.value == '<%=SUR_STATE_EDIT%>')
  361.                 {
  362.                     document.forms['frmItemType'].State.value = '<%=SUR_STATE_EDIT_REFRESH%>';
  363.                 }
  364.                 else if (document.forms['frmItemType'].State.value == '<%=SUR_STATE_INSERT%>')
  365.                 {
  366.                     document.forms['frmItemType'].State.value = '<%=SUR_STATE_INSERT_REFRESH%>';
  367.                 }
  368.  
  369.                 document.forms['frmItemType'].action = 'Item.asp';
  370.                 document.forms['frmItemType'].submit();
  371.             }
  372.         }
  373.  
  374. <%
  375.         'If the user clicked the Update button to change the number of answers, the value answered must be numeric
  376.         If CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Then
  377. %>
  378.             function insertNewAnswer()
  379.             {
  380.                 var lngAnswerCount = Number(document.forms['frmItemType'].AnswerCount.value);
  381.                 document.forms['frmItemType'].AnswerCount.value = lngAnswerCount + 1;
  382.                 if (document.forms['frmItemType'].State.value == '<%=SUR_STATE_EDIT%>')
  383.                 {
  384.                     document.forms['frmItemType'].State.value = '<%=SUR_STATE_EDIT_REFRESH%>';
  385.                 }
  386.                 document.forms['frmItemType'].action = 'Item.asp#AnswerChoices';
  387.                 document.forms['frmItemType'].submit();
  388.             }
  389. <%
  390.         End If
  391.     End If
  392.  
  393.     'If the item has responses, the only three fields that are displayed are the item text, the question alias, and
  394.     'the item sub-text.  Of these, the only field that must contain a value is the item text.  This page has two functions
  395.     'named submitCheck(), which could have been combined into a single function, in order to make the code easier
  396.     'to read and maintain.
  397.     If flgHasResponses = True Then
  398. %>
  399.         function validateForm()
  400.         {
  401.             flgReturnValue = true;
  402. <%
  403.             'If the item type has an initial question/message prompt, make sure that a value has been supplied
  404.             If CLng(lngComboItemTypeID) = SUR_ITEM_DATABASE_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_HEADING Or CLng(lngComboItemTypeID) = SUR_ITEM_MESSAGE Or CLng(lngComboItemTypeID) = SUR_ITEM_HTML Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_LINE Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_COMMENTS_BOX Or CLng(lngComboItemTypeID) = SUR_ITEM_DATE Or CLng(lngComboItemTypeID) = SUR_ITEM_NUMBER Or CLng(lngComboItemTypeID) = SUR_ITEM_YES_NO Or CLng(lngComboItemTypeID) = SUR_ITEM_TRUE_FALSE Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Or CLng(lngComboItemTypeID) = SUR_ITEM_CONSTANT_SUM Or CLng(lngComboItemTypeID) = SUR_ITEM_RANKING Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  405. %>
  406.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtItemText.value) == "")
  407.                 {
  408.                     alert("Please enter the item text.");
  409.                     document.forms['frmItemType'].txtItemText.focus();
  410.                     flgReturnValue = false;
  411.                 }
  412. <%
  413.             End If
  414.  
  415.             'If the item type is an image, make sure that the imag path is supplied
  416.             If CLng(lngComboItemTypeID) = SUR_ITEM_IMAGE Then
  417. %>
  418.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtImagePath.value) == "")
  419.                 {
  420.                     alert("Please enter a path to the image.");
  421.                     document.forms['frmItemType'].txtImagePath.focus();
  422.                     flgReturnValue = false;
  423.                 }
  424. <%
  425.             End If
  426. %>
  427.             return flgReturnValue;
  428.         }
  429. <%
  430.     Else
  431. %>
  432.  
  433.         function validateForm()
  434.         {
  435.             flgReturnValue = true;
  436.  
  437.             if (document.forms['frmItemType'].cboItemType.value == '<%=SUR_COMBO_PLEASE_SELECT%>')
  438.             {
  439.                 alert("Please select an item type.");
  440.                 document.forms['frmItemType'].cboItemType.focus();
  441.                 flgReturnValue = false;
  442.             }
  443.  
  444. <%
  445.             'If the item type has an initial question/message prompt, make sure that a value has been supplied
  446.             If CLng(lngComboItemTypeID) = SUR_ITEM_DATABASE_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_HEADING Or CLng(lngComboItemTypeID) = SUR_ITEM_MESSAGE Or CLng(lngComboItemTypeID) = SUR_ITEM_HTML Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_LINE Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_COMMENTS_BOX Or CLng(lngComboItemTypeID) = SUR_ITEM_DATE Or CLng(lngComboItemTypeID) = SUR_ITEM_NUMBER Or CLng(lngComboItemTypeID) = SUR_ITEM_YES_NO Or CLng(lngComboItemTypeID) = SUR_ITEM_TRUE_FALSE Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Or CLng(lngComboItemTypeID) = SUR_ITEM_CONSTANT_SUM Or CLng(lngComboItemTypeID) = SUR_ITEM_RANKING Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  447. %>
  448.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtItemText.value) == "")
  449.                 {
  450.                     alert("Please enter the item text.");
  451.                     document.forms['frmItemType'].txtItemText.focus();
  452.                     flgReturnValue = false;
  453.                 }
  454. <%
  455.             End If
  456.  
  457.             'For database dropdowns, make sure that both the SQL and the database connection were entered.
  458.             If CLng(lngComboItemTypeID) = SUR_ITEM_DATABASE_DROPDOWN Then
  459. %>
  460.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtDatabaseSQL.value) == "")
  461.                 {
  462.                     alert("Please enter the SQL statement for the list of answers.");
  463.                     document.forms['frmItemType'].txtDatabaseSQL.focus();
  464.                     flgReturnValue = false;
  465.                 }
  466.  
  467.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtDatabaseDSN.value) == "")
  468.                 {
  469.                     alert("Please enter the database connection string or DSN.");
  470.                     document.forms['frmItemType'].txtDatabaseDSN.focus();
  471.                     flgReturnValue = false;
  472.                 }
  473.  
  474.                 // Make sure that ItemValue and ItemDisplay are included in the SQL
  475.                 strTemp = trim(document.forms['frmItemType'].txtDatabaseSQL.value)
  476.                 if (strTemp.indexOf('ItemDisplay') == -1 || strTemp.indexOf('ItemValue') == -1)
  477.                 {
  478.                     alert("The SQL statement must contain two columns aliased as ItemValue and ItemDisplay.");
  479.                     document.forms['frmItemType'].txtDatabaseSQL.focus();
  480.                     flgReturnValue = false;
  481.                 }
  482. <%
  483.             End If
  484.  
  485.             'For text boxes, if the email address option has been checked and a default value has been provided, the default
  486.             'value must be a valid email address.
  487.             If CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_LINE Then
  488. %>
  489.                 if (flgReturnValue == true && document.forms['frmItemType'].chkEmailAddress.checked == true && trim(document.forms['frmItemType'].txtDefaultValue.value) != "" && isValidEmailAddress(document.forms['frmItemType'].txtDefaultValue.value) == false)
  490.                 {
  491.                     alert("If you supply a default value when selecting the email address format, the default value must be a valid email address.");
  492.                     document.forms['frmItemType'].txtDefaultValue.focus();
  493.                     flgReturnValue = false;
  494.                 }
  495.  
  496.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumLength.value) != '')
  497.                 {
  498.                     if (isNumeric(trim(document.forms['frmItemType'].txtMaximumLength.value)) == false)
  499.                     {
  500.                         alert("The maximum length field must contain a numeric value.");
  501.                         document.forms['frmItemType'].txtMaximumLength.focus();
  502.                         flgReturnValue = false;
  503.                     }
  504.                 }
  505. <%
  506.             End If
  507.  
  508.             'If the item type is an image, make sure that the imag path is supplied
  509.             If CLng(lngComboItemTypeID) = SUR_ITEM_IMAGE Then
  510. %>
  511.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtImagePath.value) == "")
  512.                 {
  513.                     alert("Please enter a path to the image.");
  514.                     document.forms['frmItemType'].txtImagePath.focus();
  515.                     flgReturnValue = false;
  516.                 }
  517. <%
  518.             End If
  519.  
  520.             'If the item type is a date, and a default value has been supplied, make sure that it is in the correct date format.
  521.             'Similarly, if a minimum or maximum value are supplied, they too must be valid dates.  Make sure that the minimum date
  522.             'is earlier than the maximum date and that, if supplied, the default date is not outside the date range.
  523.             If CLng(lngComboItemTypeID) = SUR_ITEM_DATE Then
  524. %>
  525.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtDefaultValue.value) != "" && <%=RenderJSDateValidationRoutineName%>(trim(document.forms['frmItemType'].txtDefaultValue.value)) == false)
  526.                 {
  527.                     document.forms['frmItemType'].txtDefaultValue.focus();
  528.                     flgReturnValue = false;
  529.                 }
  530.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMinimumValue.value) != "" && <%=RenderJSDateValidationRoutineName%>(trim(document.forms['frmItemType'].txtMinimumValue.value)) == false)
  531.                 {
  532.                     document.forms['frmItemType'].txtMinimumValue.focus();
  533.                     flgReturnValue = false;
  534.                 }
  535.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumValue.value) != "" && <%=RenderJSDateValidationRoutineName%>(trim(document.forms['frmItemType'].txtMaximumValue.value)) == false)
  536.                 {
  537.                     document.forms['frmItemType'].txtMaximumValue.focus();
  538.                     flgReturnValue = false;
  539.                 }
  540.                 if (flgReturnValue == true && isFirstDateEarlier('<%=SUR_DATE_DELIMITER%>', trim(document.forms['frmItemType'].txtMaximumValue.value), trim(document.forms['frmItemType'].txtMinimumValue.value)) == true)
  541.                 {
  542.                     alert("The date entered for the minimum value cannot be greater than the date entered for the maximum value.");
  543.                     document.forms['frmItemType'].txtMinimumValue.focus();
  544.                     flgReturnValue = false;
  545.                 }
  546.                 if (flgReturnValue == true && isFirstDateEarlier('<%=SUR_DATE_DELIMITER%>', trim(document.forms['frmItemType'].txtDefaultValue.value), trim(document.forms['frmItemType'].txtMinimumValue.value)) == true)
  547.                 {
  548.                     alert("The date entered for the default value cannot be less than the date entered for the minimum value.");
  549.                     document.forms['frmItemType'].txtMinimumValue.focus();
  550.                     flgReturnValue = false;
  551.                 }
  552.                 if (flgReturnValue == true && isFirstDateEarlier('<%=SUR_DATE_DELIMITER%>', trim(document.forms['frmItemType'].txtMaximumValue.value), trim(document.forms['frmItemType'].txtDefaultValue.value)) == true)
  553.                 {
  554.                     alert("The date entered for the default value cannot be greater than the date entered for the maximum value.");
  555.                     document.forms['frmItemType'].txtMinimumValue.focus();
  556.                     flgReturnValue = false;
  557.                 }
  558. <%
  559.             End If
  560.  
  561.             'If the item type is a matrix rating scale, make sure that numeric values have been entered for the start and
  562.             'end of the rating scale.
  563.             If CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Then
  564. %>
  565.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMinimumValue.value) == "")
  566.                 {
  567.                     alert("Please enter a value for the beginning number.");
  568.                     document.forms['frmItemType'].txtMinimumValue.focus();
  569.                     flgReturnValue = false;
  570.                 }
  571.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumValue.value) == "")
  572.                 {
  573.                     alert("Please enter a value for the ending number.");
  574.                     document.forms['frmItemType'].txtMaximumValue.focus();
  575.                     flgReturnValue = false;
  576.                 }
  577.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMinimumValue.value) != "" && isNumeric(trim(document.forms['frmItemType'].txtMinimumValue.value)) == false)
  578.                 {
  579.                     alert("Please enter a numeric value for the beginning number.");
  580.                     document.forms['frmItemType'].txtMinimumValue.focus();
  581.                     flgReturnValue = false;
  582.                 }
  583.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumValue.value) != "" && isNumeric(trim(document.forms['frmItemType'].txtMaximumValue.value)) == false)
  584.                 {
  585.                     alert("Please enter a numeric value for the ending number.");
  586.                     document.forms['frmItemType'].txtMaximumValue.focus();
  587.                     flgReturnValue = false;
  588.                 }
  589.                 if (trim(document.forms['frmItemType'].txtMaximumValue.value) != "" && trim(document.forms['frmItemType'].txtMinimumValue.value) != "")
  590.                 {
  591.                     if (flgReturnValue == true && (isFirstNumberLarger(trim(document.forms['frmItemType'].txtMinimumValue.value), trim(document.forms['frmItemType'].txtMaximumValue.value)) == true || trim(document.forms['frmItemType'].txtMaximumValue.value) == trim(document.forms['frmItemType'].txtMinimumValue.value)))
  592.                     {
  593.                         alert("The ending value must be larger than the beginning value.");
  594.                         document.forms['frmItemType'].txtMinimumValue.focus();
  595.                         flgReturnValue = false;
  596.                     }
  597.                 }
  598. <%
  599.             End If
  600.  
  601.             'If the item type is a number, and a default value has been supplied, make sure that the valued entered is numeric.
  602.             'Similarly, if a minimum or maximum value are supplied, they too must be entered as numeric values.  Make sure that
  603.             'the minimum value is less than the maximum value and that, if supplied, the default value is not outside the
  604.             'numeric range.
  605.             If CLng(lngComboItemTypeID) = SUR_ITEM_NUMBER Then
  606. %>
  607.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtDefaultValue.value) != "" && isNumeric(trim(document.forms['frmItemType'].txtDefaultValue.value)) == false)
  608.                 {
  609.                     alert("Please enter a numeric value for the default value.");
  610.                     document.forms['frmItemType'].txtDefaultValue.focus();
  611.                     flgReturnValue = false;
  612.                 }
  613.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMinimumValue.value) != "" && isNumeric(trim(document.forms['frmItemType'].txtMinimumValue.value)) == false)
  614.                 {
  615.                     alert("Please enter a numeric value for the minimum value.");
  616.                     document.forms['frmItemType'].txtMinimumValue.focus();
  617.                     flgReturnValue = false;
  618.                 }
  619.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumValue.value) != "" && isNumeric(trim(document.forms['frmItemType'].txtMaximumValue.value)) == false)
  620.                 {
  621.                     alert("Please enter a numeric value for the maximum value.");
  622.                     document.forms['frmItemType'].txtMaximumValue.focus();
  623.                     flgReturnValue = false;
  624.                 }
  625.                 if (trim(document.forms['frmItemType'].txtMaximumValue.value) != "" && trim(document.forms['frmItemType'].txtMinimumValue.value) != "")
  626.                 {
  627.                     if (flgReturnValue == true && isFirstNumberLarger(trim(document.forms['frmItemType'].txtMinimumValue.value), trim(document.forms['frmItemType'].txtMaximumValue.value)) == true)
  628.                     {
  629.                         alert("The minimum value cannot be greater than the minimum value.");
  630.                         document.forms['frmItemType'].txtMinimumValue.focus();
  631.                         flgReturnValue = false;
  632.                     }
  633.                 }
  634.                 if (trim(document.forms['frmItemType'].txtDefaultValue.value) != "" && trim(document.forms['frmItemType'].txtMinimumValue.value) != "")
  635.                 {
  636.                     if (flgReturnValue == true && isFirstNumberLarger(trim(document.forms['frmItemType'].txtMinimumValue.value), trim(document.forms['frmItemType'].txtDefaultValue.value)) == true)
  637.                     {
  638.                         alert("The default value cannot be less than the minimum value.");
  639.                         document.forms['frmItemType'].txtMinimumValue.focus();
  640.                         flgReturnValue = false;
  641.                     }
  642.                 }
  643.                 if (trim(document.forms['frmItemType'].txtMaximumValue.value) != "" && trim(document.forms['frmItemType'].txtDefaultValue.value) != "")
  644.                 {
  645.                     if (flgReturnValue == true && isFirstNumberLarger(trim(document.forms['frmItemType'].txtDefaultValue.value), trim(document.forms['frmItemType'].txtMaximumValue.value)) == true)
  646.                     {
  647.                         alert("The default value cannot be greater than the maximum value.");
  648.                         document.forms['frmItemType'].txtMaximumValue.focus();
  649.                         flgReturnValue = false;
  650.                     }
  651.                 }
  652.  
  653.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumLength.value) != '')
  654.                 {
  655.                     if (isNumeric(trim(document.forms['frmItemType'].txtMaximumLength.value)) == false)
  656.                     {
  657.                         alert("The maximum length field must contain a numeric value.");
  658.                         document.forms['frmItemType'].txtMaximumLength.focus();
  659.                         flgReturnValue = false;
  660.                     }
  661.                 }
  662. <%
  663.             End If
  664.  
  665.             'If the item type is checkboxes or open ended with multiple lines, and values were supplied for minimum and maximum
  666.             'number of values the user must select, make sure that the values supplied are numeric.
  667.             If CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  668. %>
  669.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMinimumNumberResponses.value) != "" && isNumeric(trim(document.forms['frmItemType'].txtMinimumNumberResponses.value)) == false)
  670.                 {
  671.                     alert("Please enter a numeric value for the minimum number of responses.");
  672.                     document.forms['frmItemType'].txtMinimumNumberResponses.focus();
  673.                     flgReturnValue = false;
  674.                 }
  675.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumNumberResponses.value) != "" && isNumeric(trim(document.forms['frmItemType'].txtMaximumNumberResponses.value)) == false)
  676.                 {
  677.                     alert("Please enter a numeric value for the maximum number of responses.");
  678.                     document.forms['frmItemType'].txtMaximumNumberResponses.focus();
  679.                     flgReturnValue = false;
  680.                 }
  681.                 if (trim(document.forms['frmItemType'].txtMaximumNumberResponses.value) != "" && trim(document.forms['frmItemType'].txtMinimumNumberResponses.value) != "")
  682.                 {
  683.                     if (flgReturnValue == true && isFirstNumberLarger(trim(document.forms['frmItemType'].txtMinimumNumberResponses.value), trim(document.forms['frmItemType'].txtMaximumNumberResponses.value)) == true)
  684.                     {
  685.                         alert("The minimum number of responses cannot be greater than the maximum number of responses.");
  686.                         document.forms['frmItemType'].txtMinimumNumberResponses.focus();
  687.                         flgReturnValue = false;
  688.                     }
  689.                 }
  690. <%
  691.             End If
  692.  
  693.             'For one or more line questions, allow the maximum length to be displayed
  694.             If CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  695. %>
  696.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtMaximumLength.value) != '')
  697.                 {
  698.                     if (isNumeric(trim(document.forms['frmItemType'].txtMaximumLength.value)) == false)
  699.                     {
  700.                         alert("The maximum length field must contain a numeric value.");
  701.                         document.forms['frmItemType'].txtMaximumLength.focus();
  702.                         flgReturnValue = false;
  703.                     }
  704.                 }
  705. <%
  706.             End If
  707.  
  708.             'If this is a constant sum question, make sure that if the answer total is entered, it's numeric
  709.             If CLng(lngComboItemTypeID) = SUR_ITEM_CONSTANT_SUM Then
  710. %>
  711.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtAnswerTotal.value) != "")
  712.                 {
  713.                     if (isNumeric(trim(document.forms['frmItemType'].txtAnswerTotal.value)) == false)
  714.                     {
  715.                         alert("Please enter a numeric value for the answer total.");
  716.                         document.forms['frmItemType'].txtAnswerTotal.focus();
  717.                         flgReturnValue = false;
  718.                     }
  719.                 }
  720. <%
  721.             End If
  722.  
  723.             'If this is a question that has row text (constant sum, ranking, open-ended one or more lines, or matrix,
  724.             'make sure that if the row text width is entered, it's numeric
  725.             If CLng(lngComboItemTypeID) = SUR_ITEM_CONSTANT_SUM Or CLng(lngComboItemTypeID) = SUR_ITEM_RANKING Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Or IsMatrixQuestion(lngComboItemTypeID) = True Then
  726. %>
  727.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtRowTextWidth.value) != '')
  728.                 {
  729.                     if (isNumeric(trim(document.forms['frmItemType'].txtRowTextWidth.value)) == false)
  730.                     {
  731.                         alert("The row heading width field must contain a numeric value.");
  732.                         document.forms['frmItemType'].txtRowTextWidth.focus();
  733.                         flgReturnValue = false;
  734.                     }
  735.                 }
  736. <%
  737.             End If
  738.  
  739.             'If this is a question with subitems, make sure that at least one subitem was entered.
  740.             If CLng(lngComboItemTypeID) = SUR_ITEM_CONSTANT_SUM Or CLng(lngComboItemTypeID) = SUR_ITEM_RANKING Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  741. %>
  742.                 // Check the list of subitems.  Split on the line feed, creating an array of distinct subitem records.
  743.                 var arrSubitems;
  744.                 var i;
  745.                 var flgSubitemEntered = false;
  746.                 var strSubitems = document.forms['frmItemType'].txtRowNames.value;
  747.                 arrSubitems = strSubitems.split('\n');
  748.  
  749.                 // Loop through each of the subitems
  750.                 for (i = 0; i < arrSubitems.length; i++)
  751.                 {
  752.                     // If the line has nothing but an Enter key on it, ignore it
  753.                     if (arrSubitems[i] != '\r' && trim(arrSubitems[i]) != "")
  754.                     {
  755.                         flgSubitemEntered = true;
  756.                     }
  757.                 }
  758.  
  759.                 // If no subitems were entered (every row is blank), display an error message
  760.                 if (flgReturnValue == true && flgSubitemEntered == false)
  761.                 {
  762.                     alert("Please enter at least one valid row name.");
  763.                     document.forms['frmItemType'].txtRowNames.focus();
  764.                     flgReturnValue = false;
  765.                 }
  766. <%
  767.             End If
  768.  
  769.             'Make sure that the user enters at least one answer
  770.             If CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Then
  771. %>
  772.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtAnswer1.value) == "")
  773.                 {
  774.                     alert("Please enter at least one answer, starting with the first answer text box.");
  775.                     document.forms['frmItemType'].txtAnswer1.focus();
  776.                     flgReturnValue = false;
  777.                 }
  778. <%
  779.             End If
  780.  
  781.             'For option buttons, checkboxes, and dropdowns, make sure that only numeric values are entered for the points
  782.             If CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Then
  783. %>
  784.                 if (document.forms['frmItemType'] != null)
  785.                 {
  786.                     for (i = 0; i < document.forms['frmItemType'].length; i++)
  787.                     {
  788.                         strTemp = document.forms['frmItemType'].elements[i].name;
  789.                         if (strTemp.indexOf('txtAnswerValue') > -1)
  790.                         {
  791.                             strTemp = trim(document.forms['frmItemType'].elements[i].value);
  792.                             if (strTemp.length > 0)
  793.                             {
  794.                                 if (isNumeric(trim(document.forms['frmItemType'].elements[i].value)) == false)
  795.                                 {
  796.                                     alert("Please make sure that all values entered for the points are numeric.");
  797.                                     document.forms['frmItemType'].elements[i].focus();
  798.                                     return;
  799.                                 }
  800.                             }
  801.                         }
  802.                     }
  803.                 }
  804. <%
  805.             End If
  806.  
  807.             'Make sure that the user enters at least one column heading
  808.             If CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Then
  809. %>
  810.                 if (flgReturnValue == true && trim(document.forms['frmItemType'].txtAnswer1.value) == "")
  811.                 {
  812.                     alert("Please enter at least column heading, starting with the first column heading text box.");
  813.                     document.forms['frmItemType'].txtAnswer1.focus();
  814.                     flgReturnValue = false;
  815.                 }
  816. <%
  817.             End If
  818. %>
  819.             return flgReturnValue;
  820.         }
  821. <%
  822.     End If
  823. %>
  824. function submitCheck()
  825. {
  826.     if (validateForm() == true)
  827.     {
  828.         document.forms['frmItemType'].action = 'ItemAction.asp';
  829.         document.forms['frmItemType'].submit();
  830.     }
  831. }
  832.  
  833. function itemAnswerGroupSelected()
  834. {
  835.     if (document.forms['frmItemType'].cboItemAnswerGroup.value != '-1')
  836.     {
  837.         document.forms['frmItemType'].ItemAnswerGroupSelected.value = '<%=SUR_BOOLEAN_POSITIVE%>';
  838.         if (document.forms['frmItemType'].State.value == '<%=SUR_STATE_EDIT%>')
  839.         {
  840.             document.forms['frmItemType'].State.value = '<%=SUR_STATE_EDIT_REFRESH%>';
  841.         }
  842.         document.forms['frmItemType'].action = 'Item.asp#AnswerChoices';
  843.         document.forms['frmItemType'].submit();
  844.     }
  845. }
  846. </script>
  847.  
  848. <body class="MainBodyStyle">
  849.  
  850. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  851.  
  852. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  853.     <tr>
  854.         <td height="36" valign="center">
  855.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strPageHeading%></a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#ItemTypes', 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">
  856.         </td>
  857.     </tr>
  858. </table>
  859.  
  860. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  861.  
  862. <form action="#" method="post" name="frmItemType">
  863.     <input type="hidden" name="ItemID" value="<%=lngItemID%>">
  864.     <input type="hidden" name="PageNumber" value="<%=lngPageNumber%>">
  865.     <input type="hidden" name="NewPage" value="<%=Request.Form("NewPage")%>">
  866.     <input type="hidden" name="SurveyID" value="<%=lngSurveyID%>">
  867.     <input type="hidden" name="SurveyName" value="<%=strSurveyName%>">
  868.     <input type="hidden" name="LibraryID" value="<%=lngLibraryID%>">
  869.     <input type="hidden" name="LibraryName" value="<%=strLibraryName%>">
  870.     <input type="hidden" name="State" value="<%=strState%>">
  871.     <input type="hidden" name="OrderNumber" value="<%=Request.Form("OrderNumber")%>">
  872.     <input type="hidden" name="ItemAnswerGroupSelected" value="<%=SUR_BOOLEAN_NEGATIVE%>">
  873. <%
  874.     'If this survey has responses, display a message that there are responses and that editing is limited
  875.     If flgHasResponses = True Then
  876. %>
  877.         <table width="740" border="0" cellpadding="0" cellspacing="6" class="LightGrayBackgroundColor">
  878.             <tr>
  879.                 <td width="1"></td>
  880.                 <td align="left" width="730">
  881.                     <br>
  882.                     <span class="NormalBold">
  883.                         This survey has responses.  To fully edit this item,
  884.                         you must first delete all of the responses to this survey.  Responses can be deleted by clicking
  885.                         the "Clear" icon on the <a href="SurveyList.asp">main survey list page</a>.
  886.                     </span>
  887.                 </td>
  888.                 <td width="1"> </td>
  889.             </tr>
  890.         </table>
  891. <%
  892.     End If
  893. %>
  894.     <table border="0" cellpadding="3" cellspacing="0" width="740" class="LightGrayBackgroundColor">
  895.         <tr>
  896.             <td width="1"></td>
  897.             <td height="40" valign="center">
  898.                 <table cellspacing="4" cellpadding="0" border="0" width="100%">
  899.                     <tr>
  900.                         <td width="65%" align="left">
  901.                             <span class="H2HeadingStyle"><%=strWizardHeading%></span>
  902.                         </td>
  903.                         <td width="35%" align="right">
  904.                             <span class="Required">*</span><span class="InlineHelpSpanStyle"> = Required</span>
  905.                         </td>
  906.                     </tr>
  907.                 </table>
  908.             </td>
  909.             <td width="1"> </td>
  910.         </tr>
  911.     </table>
  912.     <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr>
  913.     <table border="0" cellpadding="0" cellspacing="6" width="740" class="WhiteBackgroundColor">
  914.         <tr>
  915.             <td width="1" rowspan="50"></td>
  916.             <td valign="bottom" width="730" height="28">
  917.                 <span class="QuestionSectionHeadingSpanStyle"><label for="cboItemType">Choose an Item Type</label></span>
  918.             </td>
  919.             <td width="1" rowspan="50"> </td>
  920.         </tr>
  921.         <tr>
  922.             <td>
  923.                 <span class="Normal">Choose from over 20 item types, including four kinds of matrix questions,
  924.                     ranking questions, drop-down lists, open-ended text boxes, checkboxes, and more.
  925.                 </span>
  926.             </td>
  927.         </tr>
  928.         <tr>
  929.             <td valign="top">
  930.                 <table border="0" cellpadding="0" cellspacing="0" width="645">
  931.                     <tr>
  932.                         <td width="325">
  933. <%
  934.  
  935.                             If flgHasResponses = True Then
  936.                                 strValue = "disabled"
  937.                                 Response.Write "<input type=""hidden"" name=""cboItemType"" value=""" & lngPersistedItemTypeID & """>"
  938.                             Else
  939.                                 strValue = ""
  940.                             End If
  941. %>
  942.                             <select style="width:325px" name="cboItemType" id="cboItemType" onChange="itemTypeSelected();" <%=strValue%>>
  943.                                 <%=strItemTypes%>
  944.                             </select>
  945.                         </td>
  946.                         <td width="40" align="middle" valign="top">
  947. <%
  948.                             'Only display the link for copy an existing item in INSERT mode.
  949.                             If strState = SUR_STATE_INSERT Or strState = SUR_STATE_INSERT_REFRESH Then
  950. %>
  951.                                 <span class="Normal">or</span>
  952. <%
  953.                             Else
  954.                                 Response.Write " "
  955.                             End If
  956. %>
  957.                         </td>
  958.                         <td width="100" valign="bottom">
  959. <%
  960.                             'Only display the link for copy an existing item in INSERT mode.
  961.                             If strState = SUR_STATE_INSERT Or strState = SUR_STATE_INSERT_REFRESH Then
  962. %>
  963.                                 <a href="javascript:copyExistingItem();"><img border="0" alt="Copy an existing item" src="Resources/Buttons/CopyExistingItemSmall.gif"></a>
  964. <%
  965.                             Else
  966.                                 Response.Write " "
  967.                             End If
  968. %>
  969.                         </td>
  970.                         <td width="40" align="middle" valign="top">
  971. <%
  972.                             'Only display the link for inserting an item from a library in INSERT mode when NOT coming from a library.
  973.                             If (strState = SUR_STATE_INSERT Or strState = SUR_STATE_INSERT_REFRESH) And Len(lngLibraryID) = 0 Then
  974. %>
  975.                                 <span class="Normal">or</span>
  976. <%
  977.                             Else
  978.                                 Response.Write " "
  979.                             End If
  980. %>
  981.                         </td>
  982.                         <td width="140" valign="bottom">
  983. <%
  984.                             'Only display the link for inserting an item from a library in INSERT mode when NOT coming from a library.
  985.                             If (strState = SUR_STATE_INSERT Or strState = SUR_STATE_INSERT_REFRESH) And Len(lngLibraryID) = 0 Then
  986. %>
  987.                                 <a href="javascript:insertFromLibrary();"><img border="0" alt="Insert an item from a library" src="Resources/Buttons/InsertFromLibrarySmall.gif"></a>
  988. <%
  989.                             Else
  990.                                 Response.Write " "
  991.                             End If
  992. %>
  993.                         </td>
  994.                     </tr>
  995.                 </table>
  996.             </td>
  997.         </tr>
  998. <%
  999.         'If the control type is an image, display a file input control
  1000.         If CLng(lngComboItemTypeID) = SUR_ITEM_IMAGE Then
  1001. %>
  1002.             <tr>
  1003.                 <td valign="top">
  1004.                     <span class="QuestionSectionHeadingSpanStyle">
  1005.                         <label for="txtImagePath">Enter the Image Path</label>
  1006.                     </span>
  1007.                     <br>
  1008.                     <span class="InlineHelpSpanStyle">
  1009.                         <span class="InlineHelpSpanStyleBold">Enter the path to the image.</span><span class="Required">*</span>  Use a full HTTP path, a relative path, or a path using a virtual directory.<br>
  1010.                     </span>
  1011.                     <input type="text" value="<%=strImagePath%>" name="txtImagePath" id="txtImagePath" maxlength="150" style="width:700px">
  1012.                 </td>
  1013.             </tr>
  1014. <%
  1015.         'If the control type is a horizontal rule <hr>, display a comment an example
  1016.         ElseIf CLng(lngComboItemTypeID) = SUR_ITEM_HORIZONTAL_RULE Then
  1017. %>
  1018.             <tr>
  1019.                 <td valign="top">
  1020.                     <span class="QuestionSectionHeadingSpanStyle">
  1021.                         Insert a Horizontal Rule
  1022.                     </span>
  1023.                     <br>
  1024.                     <span class="InlineHelpSpanStyle">
  1025.                         This item inserts an HTML horizontal rule element, as shown in the example below.
  1026.                     </span>
  1027.                 </td>
  1028.             </tr>
  1029.             <tr>
  1030.                 <td valign="top">
  1031.                     <span class="QuestionSectionHeadingSpanStyle">
  1032.                         <br>Example:<br>
  1033.                     </span>
  1034.                     <hr>
  1035.                 </td>
  1036.             </tr>
  1037. <%
  1038.         End If
  1039.  
  1040.         'If the control type requires a question-type input, display the large text area prompt at the
  1041.         'beginning of the page
  1042.         If DisplayControl(SUR_CONTROL_QUESTION, lngComboItemTypeID) = True Then
  1043. %>
  1044.             <tr>
  1045.                 <td height="32" valign="bottom">
  1046.                     <span class="QuestionSectionHeadingSpanStyle">
  1047. <%
  1048.                     'Display different text for the initial prompt depending on the item type
  1049.                     Select Case CLng(lngComboItemTypeID)
  1050.                         Case SUR_ITEM_MESSAGE:
  1051. %>
  1052.                             Message
  1053. <%
  1054.                         Case SUR_ITEM_HEADING:
  1055. %>
  1056.                             Heading
  1057. <%
  1058.                         Case SUR_ITEM_HTML:
  1059. %>
  1060.                             HTML
  1061. <%
  1062.                         Case Else:
  1063. %>
  1064.                             Question
  1065. <%
  1066.                     End Select
  1067. %>
  1068.                     </span>
  1069.                 </td>
  1070.             </tr>
  1071.             <tr>
  1072.                 <td>
  1073. <%
  1074.                         'Display different sub-text for the initial prompt depending on the item type
  1075.                         Select Case CLng(lngComboItemTypeID)
  1076.                             Case SUR_ITEM_MESSAGE:
  1077.                                 lngRows = 6
  1078. %>
  1079.                                 <span class="InlineHelpSpanStyleBold"><label for="txtItemText">Enter the message.</label></span><span class="Required">*</span>  <span class="InlineHelpSpanStyle">Enter the text for the message.<br></span>
  1080. <%
  1081.                             Case SUR_ITEM_HEADING:
  1082.                                 lngRows = 2
  1083. %>
  1084.                                 <span class="InlineHelpSpanStyleBold"><label for="txtItemText">Enter the heading.</label></span><span class="Required">*</span>  <span class="InlineHelpSpanStyle">Enter the text for the heading.<br></span>
  1085. <%
  1086.                             Case SUR_ITEM_HTML:
  1087.                                 lngRows = 10
  1088. %>
  1089.                                 <span class="InlineHelpSpanStyleBold"><label for="txtItemText">Enter the HTML.</label></span><span class="Required">*</span>  <span class="InlineHelpSpanStyle">Use this field to enter any HTML and/or content.  Text will be displayed using the HTML tags you enter.<br></span>
  1090. <%
  1091.                             Case Else:
  1092.                                 lngRows = 2
  1093. %>
  1094.                                 <span class="InlineHelpSpanStyleBold"><label for="txtItemText">Enter the question.</label></span><span class="Required">*</span>  <span class="InlineHelpSpanStyle">Use this field to enter the text for your question or input prompt.<br></span>
  1095. <%
  1096.                         End Select
  1097. %>
  1098.                     <textarea class="TextareaStyle" name="txtItemText" id="txtItemText" style="width:700" rows="<%=lngRows%>"><%=Server.HTMLEncode(strItemText)%></textarea>
  1099.                 </td>
  1100.             </tr>
  1101. <%
  1102.             If CLng(lngComboItemTypeID) <> SUR_ITEM_HEADING And CLng(lngComboItemTypeID) <> SUR_ITEM_HTML And CLng(lngComboItemTypeID) <> SUR_ITEM_MESSAGE Then
  1103. %>
  1104.                 <tr>
  1105.                     <td valign="top">
  1106.                         <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtItemAlias">Enter the question alias.</label></span>  Enter alternate text for use in the reports.  If blank, the actual question will be displayed.<br></span>
  1107.                         <textarea class="TextareaStyle" name="txtItemAlias" id="txtItemAlias" style="width:700" rows="2"><%=Server.HTMLEncode(strItemAlias)%></textarea>
  1108.                     </td>
  1109.                 </tr>
  1110.                 <tr>
  1111.                     <td valign="top">
  1112.                         <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtItemSubText">Enter the sub-text.</label></span>  Enter informational or additional text to display below the question.</span>
  1113.                         <textarea class="TextareaStyle" name="txtItemSubText" id="txtItemSubText" style="width:700" rows="4"><%=Server.HTMLEncode(strItemSubText)%></textarea>
  1114.                     </td>
  1115.                 </tr>
  1116. <%
  1117.             End If
  1118.  
  1119.             If CLng(lngComboItemTypeID) = SUR_ITEM_DATABASE_DROPDOWN Then
  1120. %>
  1121.                 <tr>
  1122.                     <td valign="top">
  1123.                         <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtDatabaseSQL">Enter the SQL.</label></span><span class="Required">*</span>  The SQL must contain two columns aliased as ItemValue and ItemDisplay.<br></span>
  1124.                         <textarea class="TextareaStyle" name="txtDatabaseSQL" id="txtDatabaseSQL" style="width:700" rows="4"><%=strDatabaseSQL%></textarea>
  1125.                     </td>
  1126.                 </tr>
  1127.                 <tr>
  1128.                     <td valign="top">
  1129.                         <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtDatabaseDSN">Enter the connection string.</label></span><span class="Required">*</span>  Enter the DSN or connection string to connect to the database for this query.<br></span>
  1130.                         <input type="text" name="txtDatabaseDSN" id="txtDatabaseDSN" value="<%=strDatabaseDSN%>" style="width:700px">
  1131.                     </td>
  1132.                 </tr>
  1133. <%
  1134.             End If
  1135.         End If 'Display of question prompt
  1136.  
  1137.         'Only display the options for question types that have options, and make sure that the survey does not have
  1138.         'any responses
  1139.         If DisplayControl(SUR_CONTROL_HAS_OPTIONS, lngComboItemTypeID) = True And flgHasResponses = False Then
  1140. %>
  1141.             <tr>
  1142.                 <td valign="bottom" height="34">
  1143.                     <span class="QuestionSectionHeadingSpanStyle"><label for="chkRequired">Options</label></span>
  1144.                     <label for="chkRandomOrder"> </label><label for="chkEmailAddress"> </label>
  1145.                 </td>
  1146.             </tr>
  1147. <%
  1148.             If DisplayControl(SUR_CONTROL_REQUIRED, lngComboItemTypeID) = True Then
  1149. %>
  1150.                 <tr>
  1151.                     <td valign="top">
  1152.                         <input type="checkbox" <% If strRequiredYesNo = SUR_BOOLEAN_POSITIVE Then Response.Write "checked " End If %> name="chkRequired" id="chkRequired">
  1153.                         <span class="InlineHelpSpanStyleBold">Required.</span>  <span class="InlineHelpSpanStyle">Check this box if an answer to this question is required.</span>
  1154.                     </td>
  1155.                 </tr>
  1156. <%
  1157.             End If
  1158.  
  1159.             If DisplayControl(SUR_CONTROL_RANDOM_ORDER, lngComboItemTypeID) = True Then
  1160. %>
  1161.                 <tr>
  1162.                     <td valign="top">
  1163.                         <input type="checkbox" <% If strRandomOrderYesNo = SUR_BOOLEAN_POSITIVE Then Response.Write "checked " End If %> name="chkRandomOrder" id="chkRandomOrder">
  1164.                         <span class="InlineHelpSpanStyleBold">Random Order.</span>  <span class="InlineHelpSpanStyle">Check this box if the answers to this question should be displayed in random order.</span>
  1165.                     </td>
  1166.                 </tr>
  1167. <%
  1168.             End If
  1169.  
  1170.             'Display different types of input controls for other options depending on the question type
  1171.             Select Case CLng(lngComboItemTypeID)
  1172.                 Case SUR_ITEM_OPEN_ENDED_ONE_LINE:
  1173. %>
  1174.                     <tr>
  1175.                         <td valign="top">
  1176.                             <input type="checkbox" <% If strEmailAddressYesNo = SUR_BOOLEAN_POSITIVE Then Response.Write "checked " End If %> name="chkEmailAddress" id="chkEmailAddress">
  1177.                             <span class="InlineHelpSpanStyleBold">Email address.</span>  <span class="InlineHelpSpanStyle">Check this box if the answer to this question must be a valid email address.</span>
  1178.                         </td>
  1179.                     </tr>
  1180.                     <tr>
  1181.                         <td valign="top">
  1182.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtDatabaseDSN">Default value.</label></span>  The value entered below will be displayed as the default for this question.<br></span>
  1183.                             <input type="text" name="txtDefaultValue" id="txtDefaultValue" value="<%=strDefaultValue%>" style="width:700px">
  1184.                         </td>
  1185.                     </tr>
  1186. <%
  1187.                 Case SUR_ITEM_SINGLE_SELECT_OPTIONS
  1188. %>
  1189.                     <tr>
  1190.                         <td valign="top">
  1191.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboDisplayType">Answer alignment.</label></span><span class="Required">*</span>  Select the way answers should be aligned on the page.<br></span>
  1192.                             <select name="cboDisplayType" id="cboDisplayType" style="width:250px">
  1193.                                 <option <% If strDisplayFormat = SUR_ANSWER_ALIGNMENT_HORIZONTAL Then Response.Write "SELECTED" End If %> value="<%=SUR_ANSWER_ALIGNMENT_HORIZONTAL%>"><%=SUR_ANSWER_ALIGNMENT_HORIZONTAL%></option>
  1194.                                 <option <% If strDisplayFormat = SUR_ANSWER_ALIGNMENT_VERTICAL Then Response.Write "SELECTED" End If %> value="<%=SUR_ANSWER_ALIGNMENT_VERTICAL%>"><%=SUR_ANSWER_ALIGNMENT_VERTICAL%></option>
  1195.                             </select>
  1196.                         </td>
  1197.                     </tr>
  1198. <%
  1199.                 Case SUR_ITEM_CONSTANT_SUM
  1200. %>
  1201.                     <tr>
  1202.                         <td valign="top">
  1203.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtDatabaseDSN">Answer total.</label></span>  Enter the total that the value must add up to.  To allow any total, leave this field blank.<br></span>
  1204.                             <input type="text" name="txtAnswerTotal" id="txtAnswerTotal" value="<%=strAnswerTotal%>" style="width:250px">
  1205.                         </td>
  1206.                     </tr>
  1207. <%
  1208.                 Case SUR_ITEM_MULTISELECT_CHECKBOXES, SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES:
  1209.                     'The alignment option should only be displayed for checkboxes
  1210.                     If CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Then
  1211. %>
  1212.                         <tr>
  1213.                             <td valign="top">
  1214.                                 <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboDisplayType">Answer alignment.</label></span><span class="Required">*</span>  Select the way answers should be aligned on the page.<br></span>
  1215.                                 <select name="cboDisplayType" id="cboDisplayType" style="width:250px">
  1216.                                     <option <% If strDisplayFormat = SUR_ANSWER_ALIGNMENT_VERTICAL Then Response.Write "SELECTED" End If %> value="<%=SUR_ANSWER_ALIGNMENT_VERTICAL%>"><%=SUR_ANSWER_ALIGNMENT_VERTICAL%></option>
  1217.                                     <option <% If strDisplayFormat = SUR_ANSWER_ALIGNMENT_HORIZONTAL Then Response.Write "SELECTED" End If %> value="<%=SUR_ANSWER_ALIGNMENT_HORIZONTAL%>"><%=SUR_ANSWER_ALIGNMENT_HORIZONTAL%></option>
  1218.                                 </select>
  1219.                             </td>
  1220.                         </tr>
  1221. <%
  1222.                     End If
  1223. %>
  1224.                     <tr>
  1225.                         <td valign="top">
  1226. <%
  1227.                             'The prompt displayed varies depending on the question type
  1228.                             If CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Then
  1229. %>
  1230.                                 <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMinimumNumberResponses">Minimum number of responses.</label></span>  Enter the minimum number of checkboxes that must be checked.<br></span>
  1231. <%
  1232.                             Else 'Must be open ended with one or more lines
  1233. %>
  1234.                                 <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMinimumNumberResponses">Minimum number of responses.</label></span>  Enter the minimum number of responses that must be entered.<br></span>
  1235. <%
  1236.                             End If
  1237. %>
  1238.                             <input type="text" name="txtMinimumNumberResponses" id="txtMinimumNumberResponses" value="<%=strMinimumNumberResponses%>" style="width:250px">
  1239.                         </td>
  1240.                     </tr>
  1241.                     <tr>
  1242.                         <td valign="top">
  1243. <%
  1244.                             'The prompt displayed varies depending on the question type
  1245.                             If CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Then
  1246. %>
  1247.                                 <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMaximumNumberResponses">Maximum number of responses.</label></span>  Enter the maximum number of checkboxes that can be checked.<br></span>
  1248. <%
  1249.                             Else 'Must be open ended with one or more lines
  1250. %>
  1251.                                 <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMaximumNumberResponses">Maximum number of responses.</label></span>  Enter the maximum number of responses that must be entered.<br></span>
  1252. <%
  1253.                             End If
  1254. %>
  1255.                             <input type="text" name="txtMaximumNumberResponses" id="txtMaximumNumberResponses" value="<%=strMaximumNumberResponses%>" style="width:250px">
  1256.                         </td>
  1257.                     </tr>
  1258. <%
  1259.                 Case SUR_ITEM_IMAGE:
  1260. %>
  1261.                     <tr>
  1262.                         <td valign="top">
  1263.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtImageHeight">Image height.</label></span>  To change the height of the image, enter a value below.<br></span>
  1264.                             <input type="text" name="txtImageHeight" id="txtImageHeight" value="<%=strImageHeight%>" style="width:250px">
  1265.                         </td>
  1266.                     </tr>
  1267.                     <tr>
  1268.                         <td valign="top">
  1269.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtImageWidth">Image width.</label></span>  To change the width of the image, enter a value below.<br></span>
  1270.                             <input type="text" name="txtImageWidth" id="txtImageWidth" value="<%=strImageWidth%>" style="width:250px">
  1271.                         </td>
  1272.                     </tr>
  1273.                     <tr>
  1274.                         <td valign="top">
  1275.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboImageAlignment">Image alignment.</label></span>  Select the horizontal alignment for how the image should be displayed.<br></span>
  1276.                             <select name="cboImageAlignment" id="cboImageAlignment" style="width:250px">
  1277.                                 <option <% If strImageAlignment = SUR_IMAGE_ALIGNMENT_DEFAULT Then Response.Write "SELECTED" End If %> value="<%=SUR_IMAGE_ALIGNMENT_DEFAULT%>"><%=SUR_IMAGE_ALIGNMENT_DEFAULT%></option>
  1278.                                 <option <% If strImageAlignment = SUR_IMAGE_ALIGNMENT_LEFT Then Response.Write "SELECTED" End If %> value="<%=SUR_IMAGE_ALIGNMENT_LEFT%>"><%=SUR_IMAGE_ALIGNMENT_LEFT%></option>
  1279.                                 <option <% If strImageAlignment = SUR_IMAGE_ALIGNMENT_CENTER Then Response.Write "SELECTED" End If %> value="<%=SUR_IMAGE_ALIGNMENT_CENTER%>"><%=SUR_IMAGE_ALIGNMENT_CENTER%></option>
  1280.                                 <option <% If strImageAlignment = SUR_IMAGE_ALIGNMENT_RIGHT Then Response.Write "SELECTED" End If %> value="<%=SUR_IMAGE_ALIGNMENT_RIGHT%>"><%=SUR_IMAGE_ALIGNMENT_RIGHT%></option>
  1281.                             </select>
  1282.                         </td>
  1283.                     </tr>
  1284. <%
  1285.                 Case SUR_ITEM_DATE:
  1286. %>
  1287.                     <tr>
  1288.                         <td valign="top">
  1289.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtDefaultValue">Default value.</label></span>  The date entered below will be the default value.  Format for the date is <%=DisplayInternationalizedDateFormat%>.<br></span>
  1290.                             <input type="text" name="txtDefaultValue" id="txtDefaultValue" value="<%=strDefaultValue%>" style="width:250px">
  1291.                         </td>
  1292.                     </tr>
  1293.                     <tr>
  1294.                         <td valign="top">
  1295.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMinimumValue">Minimum value.</label></span>  Enter the earliest acceptable date.  Format for the date is <%=DisplayInternationalizedDateFormat%>.<br></span>
  1296.                             <input type="text" name="txtMinimumValue" id="txtMinimumValue" value="<%=strMinimumValue%>" style="width:250px">
  1297.                         </td>
  1298.                     </tr>
  1299.                     <tr>
  1300.                         <td valign="top">
  1301.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMaximumValue">Maximum value.</label></span>  Enter the latest acceptable date.  Format for the date is <%=DisplayInternationalizedDateFormat%>.<br></span>
  1302.                             <input type="text" name="txtMaximumValue" id="txtMaximumValue" value="<%=strMaximumValue%>" style="width:250px">
  1303.                         </td>
  1304.                     </tr>
  1305. <%
  1306.                 Case SUR_ITEM_NUMBER:
  1307. %>
  1308.                     <tr>
  1309.                         <td valign="top">
  1310.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtDefaultValue">Default value.</label></span>  The value entered below will be displayed as the default for this question.<br></span>
  1311.                             <input type="text" maxlength="8" name="txtDefaultValue" id="txtDefaultValue" value="<%=strDefaultValue%>" style="width:250px">
  1312.                         </td>
  1313.                     </tr>
  1314.                     <tr>
  1315.                         <td valign="top">
  1316.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMinimumValue"> Minimum value.</label></span>  Enter the smallest acceptable numeric value.<br></span>
  1317.                             <input type="text" name="txtMinimumValue" id="txtMinimumValue" value="<%=strMinimumValue%>" style="width:250px">
  1318.                         </td>
  1319.                     </tr>
  1320.                     <tr>
  1321.                         <td valign="top">
  1322.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMaximumValue">Maximum value.</label></span>  Enter the largest acceptable numeric value.<br></span>
  1323.                             <input type="text" name="txtMaximumValue" id="txtMaximumValue" value="<%=strMaximumValue%>" style="width:250px">
  1324.                         </td>
  1325.                     </tr>
  1326. <%
  1327.                 Case SUR_ITEM_MATRIX_RATING_SCALE:
  1328. %>
  1329.                     <tr>
  1330.                         <td valign="top">
  1331.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMinimumValue">Beginning number.</label></span>  Enter the first number for the rating scale.<br></span>
  1332.                             <input type="text" name="txtMinimumValue" id="txtMinimumValue" value="<%=strMinimumValue%>" style="width:250px">
  1333.                         </td>
  1334.                     </tr>
  1335.                     <tr>
  1336.                         <td valign="top">
  1337.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><lable for="txtMaximumValue">Ending number.</label></span>  Enter the last number for the rating scale.<br></span>
  1338.                             <input type="text" name="txtMaximumValue" id="txtMaximumValue" value="<%=strMaximumValue%>" style="width:250px">
  1339.                         </td>
  1340.                     </tr>
  1341. <%
  1342.                 Case SUR_ITEM_OPEN_ENDED_COMMENTS_BOX:
  1343. %>
  1344.                     <tr>
  1345.                         <td valign="top">
  1346.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtDefaultValue">Default value.</label></span>  The value entered below will be displayed as the default for this question.<br></span>
  1347.                             <textarea class="TextareaStyle" name="txtDefaultValue" id="txtDefaultValue" style="width:700" rows="4"><%=Server.HTMLEncode(strDefaultValue)%></textarea>
  1348.                         </td>
  1349.                     </tr>
  1350. <%
  1351.                 Case SUR_ITEM_YES_NO:
  1352. %>
  1353.                     <tr>
  1354.                         <td valign="top">
  1355.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboDefaultValue">Default value.</label></span>  This value will be selected as the default for this question.<br></span>
  1356.                             <select name="cboDefaultValue" id="cboDefaultValue" style="width:250px">
  1357.                                 <option <% If strDefaultValue = SUR_COMBO_NONE Then Response.Write "SELECTED" End If %> value="<%=SUR_COMBO_NONE%>"><%=SUR_COMBO_NONE%></option>
  1358.                                 <option <% If strDefaultValue = 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>
  1359.                                 <option <% If strDefaultValue = 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>
  1360.                             </select>
  1361.                         </td>
  1362.                     </tr>
  1363.                     <tr>
  1364.                         <td valign="top">
  1365.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboDisplayType">Display type.</label></span><span class="Required">*</span>  Select the format for the response to the Yes/No question.<br></span>
  1366.                             <select name="cboDisplayType" id="cboDisplayType" style="width:250px">
  1367.                                 <option <% If strDisplayFormat = SUR_BOOLEAN_QUESTION_FORMAT_1 Then Response.Write "SELECTED" End If %> value="<%=SUR_BOOLEAN_QUESTION_FORMAT_1%>"><%=SUR_BOOLEAN_QUESTION_FORMAT_1%></option>
  1368.                                 <option <% If strDisplayFormat = SUR_BOOLEAN_QUESTION_FORMAT_2 Then Response.Write "SELECTED" End If %> value="<%=SUR_BOOLEAN_QUESTION_FORMAT_2%>"><%=SUR_BOOLEAN_QUESTION_FORMAT_2%></option>
  1369.                                 <option <% If strDisplayFormat = SUR_BOOLEAN_QUESTION_FORMAT_3 Then Response.Write "SELECTED" End If %> value="<%=SUR_BOOLEAN_QUESTION_FORMAT_3%>"><%=SUR_BOOLEAN_QUESTION_FORMAT_3%></option>
  1370.                             </select>
  1371.                         </td>
  1372.                     </tr>
  1373. <%
  1374.                 Case SUR_ITEM_TRUE_FALSE:
  1375. %>
  1376.                     <tr>
  1377.                         <td valign="top">
  1378.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboDefaultValue">Default value.</label></span>  This value will be selected as the default for this question.<br></span>
  1379.                             <select name="cboDefaultValue" id="cboDefaultValue" style="width:250px">
  1380.                                 <option <% If strDefaultValue = SUR_COMBO_NONE Then Response.Write "SELECTED" End If %> value="<%=SUR_COMBO_NONE%>"><%=SUR_COMBO_NONE%></option>
  1381.                                 <option <% If strDefaultValue = 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>
  1382.                                 <option <% If strDefaultValue = 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>
  1383.                             </select>
  1384.                         </td>
  1385.                     </tr>
  1386.                     <tr>
  1387.                         <td valign="top">
  1388.                             <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboDisplayType">Display type.</label></span><span class="Required">*</span>  Select the format for the response to the True/False question.<br></span>
  1389.                             <select name="cboDisplayType" id="cboDisplayType" style="width:250px">
  1390.                                 <option <% If strDisplayFormat = SUR_BOOLEAN_QUESTION_FORMAT_1 Then Response.Write "SELECTED" End If %> value="<%=SUR_BOOLEAN_QUESTION_FORMAT_1%>"><%=SUR_BOOLEAN_QUESTION_FORMAT_1%></option>
  1391.                                 <option <% If strDisplayFormat = SUR_BOOLEAN_QUESTION_FORMAT_2 Then Response.Write "SELECTED" End If %> value="<%=SUR_BOOLEAN_QUESTION_FORMAT_2%>"><%=SUR_BOOLEAN_QUESTION_FORMAT_2%></option>
  1392.                                 <option <% If strDisplayFormat = SUR_BOOLEAN_QUESTION_FORMAT_3 Then Response.Write "SELECTED" End If %> value="<%=SUR_BOOLEAN_QUESTION_FORMAT_3%>"><%=SUR_BOOLEAN_QUESTION_FORMAT_3%></option>
  1393.                             </select>
  1394.                         </td>
  1395.                     </tr>
  1396. <%
  1397.             End Select
  1398.  
  1399.             'Optionally display an option for the maximum number of characters
  1400.             If DisplayControl(SUR_CONTROL_MAXIMUM_LENGTH, lngComboItemTypeID) = True Then
  1401. %>
  1402.                 <tr>
  1403.                     <td valign="top">
  1404.                         <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtMaximumLength">Maximum length.</label></span>  Enter the maximum number of allowable characters for this question.<br></span>
  1405.                         <input type="text" maxlength="5" name="txtMaximumLength" id="txtMaximumLength" value="<%=strMaximumLength%>" style="width:250px">
  1406.                     </td>
  1407.                 </tr>
  1408. <%
  1409.             End If
  1410.  
  1411.             'Optionally display an option for the width of the row text
  1412.             If DisplayControl(SUR_CONTROL_ROW_TEXT_WIDTH, lngComboItemTypeID) = True Then
  1413. %>
  1414.                 <tr>
  1415.                     <td valign="top">
  1416.                         <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="txtRowTextWidth">Row heading width.</label></span>  Enter the width, in pixels, of the column for the row headings.<br></span>
  1417.                         <input type="text" maxlength="3" name="txtRowTextWidth" id="txtRowTextWidth" value="<%=strRowTextWidth%>" style="width:250px">
  1418.                     </td>
  1419.                 </tr>
  1420. <%
  1421.             End If
  1422.         End If
  1423.  
  1424.         'Display the rows input section only for these item types that require rows, and make sure the survey does not
  1425.         'have any responses
  1426.         If DisplayControl(SUR_CONTROL_ROWS, lngComboItemTypeID) = True And flgHasResponses = False Then
  1427.             'In edit mode, select all of the row names for this item, iterate through them, and
  1428.             'create a string that will be used to display the values.
  1429.             If strState = SUR_STATE_EDIT Then
  1430.                 strSQL = "SELECT subitem_text FROM sur_subitem WHERE item_id = " & lngItemID & " ORDER BY order_number"
  1431.                 rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, , adCmdText
  1432.                 'Make sure that there are existing subitems.  A user may edit the question by changing the question from
  1433.                 'a type that does not have subitems to one that does, which would mean there are no existing subitems
  1434.                 If Not rsSubItems.EOF Then
  1435.                     rsSubItems.MoveFirst
  1436.                     Do While Not rsSubItems.EOF
  1437.                         strRowNames = strRowNames & rsSubItems("subitem_text") & vbCrLf
  1438.                         rsSubItems.MoveNext
  1439.                     Loop
  1440.                 End If
  1441.                 rsSubItems.Close
  1442.                 Set rsSubItems = Nothing
  1443.             End If
  1444. %>
  1445.             <tr>
  1446.                 <td valign="top">
  1447.                     <span class="QuestionSectionHeadingSpanStyle">Rows</span>
  1448.                     <br>
  1449.                     <span class="InlineHelpSpanStyleBold"><label for="txtRowNames">Row names.</label></span><span class="Required">*</span> <span class="InlineHelpSpanStyle">Enter each row name on a separate line below.</span><br>
  1450.                     <textarea class="TextareaStyle" name="txtRowNames" id="txtRowNames" style="width:700" rows="4"><%=Server.HTMLEncode(strRowNames)%></textarea>
  1451.                 </td>
  1452.             </tr>
  1453. <%
  1454.         End If
  1455.  
  1456.         'Display the answer input section only for these item types that require answers, and make sure the survey
  1457.         'does not have any responses
  1458.         If DisplayControl(SUR_CONTROL_ANSWER, lngComboItemTypeID) = True And flgHasResponses = False Then
  1459.  
  1460.             'If the user just selected a group from the combo box of answer groups, query for the values.  Otherwise,
  1461.             'in EDIT mode or COPY EXISTING QUESTION mode, query to get all of the previously entered
  1462.             'answers to this question.
  1463.             If Request.Form("ItemAnswerGroupSelected") = SUR_BOOLEAN_POSITIVE Then
  1464.                 strSQL = "SELECT answer_1, answer_2, answer_3, answer_4, answer_5 FROM sur_item_answer_group " & _
  1465.                          "WHERE item_answer_group_id = " & Request.Form("cboItemAnswerGroup")
  1466.                 rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, , adCmdText
  1467.             ElseIf strState = SUR_STATE_EDIT Or strState = SUR_STATE_EDIT_REFRESH Then
  1468.                 strSQL = "SELECT answer_value, default_yn, answer_text FROM sur_item_answer WHERE item_id = " & lngItemID & " ORDER BY order_number"
  1469.                 rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  1470.             End If
  1471.  
  1472.             'Determine the number of answers fields to display
  1473.             If Request.Form("ItemAnswerGroupSelected") = SUR_BOOLEAN_POSITIVE Then
  1474.                 lngAnswerCount = SUR_MAXIMUM_ANSWER_GROUP_COUNT
  1475.             ElseIf Len(Request.Form("AnswerCount")) > 0 Then
  1476.                 lngAnswerCount = Request.Form("AnswerCount")
  1477.             ElseIf strState = SUR_STATE_EDIT Or strState = SUR_STATE_EDIT_REFRESH Then
  1478.                 'In edit mode, count up the total number of responses
  1479.                 lngAnswerCount = 0
  1480.  
  1481.                 'If there are answers, count them; otherwise, use the default value.
  1482.                 If rsAnswers.EOF = True Then
  1483.                     lngAnswerCount = SUR_DEFAULT_ANSWER_COUNT
  1484.                 Else
  1485.                     Do While Not rsAnswers.EOF
  1486.                         lngAnswerCount = lngAnswerCount + 1
  1487.                         rsAnswers.MoveNext
  1488.                     Loop
  1489.                     rsAnswers.MoveFirst
  1490.                 End If
  1491.             Else
  1492.                 lngAnswerCount = SUR_DEFAULT_ANSWER_COUNT
  1493.             End If
  1494. %>
  1495.             <tr>
  1496.                 <td valign="top">
  1497. <%
  1498.                     'The heading of this section depends on the item type being displayed.
  1499.                     If IsMatrixQuestion(lngComboItemTypeID) = True Then
  1500. %>
  1501.                         <span class="QuestionSectionHeadingSpanStyle">Columns</span>
  1502. <%
  1503.                     Else
  1504. %>
  1505.                         <span class="QuestionSectionHeadingSpanStyle">Answers</span>
  1506. <%
  1507.                     End If
  1508. %>
  1509.                 </td>
  1510.             </tr>
  1511.             <tr>
  1512.                 <td valign="top">
  1513.                     <a name="#AnswerChoices">
  1514. <%
  1515.                     'The wording for this section depends on the item type being displayed.
  1516.                     If IsMatrixQuestion(lngComboItemTypeID) = True Then
  1517. %>
  1518.                         <span class="InlineHelpSpanStyleBold"><label for="cboItemAnswerGroup">Select column headings.</label></span> <span class="InlineHelpSpanStyle">Select a group of column headings or enter the headings below.</span><br>
  1519. <%
  1520.                     Else
  1521. %>
  1522.                         <span class="InlineHelpSpanStyleBold"><label for="cboItemAnswerGroup">Select answer choices.</label></span> <span class="InlineHelpSpanStyle">Select a group of answers or enter the answers below.</span><br>
  1523. <%
  1524.                     End If
  1525. %>
  1526.                     <select style="width:350px" name="cboItemAnswerGroup" id="cboItemAnswerGroup" onChange="javascript:itemAnswerGroupSelected();">
  1527. <%
  1528.                         'The wording for this section depends on the item type being displayed.
  1529.                         If IsMatrixQuestion(lngComboItemTypeID) = True Then
  1530. %>
  1531.                             <option value="-1"> Select column headings group (optional)</option>
  1532. <%
  1533.                         Else
  1534. %>
  1535.                             <option value="-1"> Select answer group (optional)</option>
  1536. <%
  1537.                         End If
  1538.  
  1539.                         'Create options for all of the answer groups
  1540.                         strSQL = "SELECT item_answer_group_id, item_answer_group_name, answer_1, answer_2, answer_3, answer_4, answer_5 " & _
  1541.                                  "FROM sur_item_answer_group " & _
  1542.                                  "ORDER BY item_answer_group_name"
  1543.                         rsAnswerGroups.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, , adCmdText
  1544.                         If Not rsAnswerGroups.EOF Then
  1545.                             Do While Not rsAnswerGroups.EOF
  1546. %>
  1547.                                 <option <% If CStr(rsAnswerGroups("item_answer_group_id")) = CStr(Request.Form("cboItemAnswerGroup")) Then Response.Write "selected" End If %> value="<%=rsAnswerGroups("item_answer_group_id")%>"><%=rsAnswerGroups("item_answer_group_name")%></option>
  1548. <%
  1549.                                 rsAnswerGroups.MoveNext
  1550.                             Loop
  1551.                         End If
  1552.                         rsAnswerGroups.Close
  1553.                         Set rsAnswerGroups = Nothing
  1554. %>
  1555.                     </select>
  1556.                     <br>
  1557. <%
  1558.                     'The wording for this section depends on the item type being displayed.
  1559.                     If IsMatrixQuestion(lngComboItemTypeID) = True Then
  1560. %>
  1561.                         <span class="InlineHelpSpanStyleBold">Enter the column headings.</span><span class="Required">*</span> <span class="InlineHelpSpanStyle">Enter each of the column headings in the text boxes below.</span><br>
  1562. <%
  1563.                     Else
  1564. %>
  1565.                         <span class="InlineHelpSpanStyleBold">Enter the answers.</span><span class="Required">*</span> <span class="InlineHelpSpanStyle">Enter each of the answers in the text boxes below.</span><br>
  1566. <%
  1567.                     End If
  1568. %>
  1569.                     <table cellspacing="0" cellpadding="0" border="0" width="100%">
  1570.  
  1571. <%
  1572.                         'Display the specified number of input controls for the answers
  1573.                         For i = 1 To lngAnswerCount
  1574. %>
  1575.                             <tr>
  1576.                                 <td align="left" width="25"><span class="InlineHelpSpanStyle"><label for="txtAnswer<%=i%>"><%=i%></label></span></td>
  1577.                                 <td align="left">
  1578. <%
  1579.                                     'If the user just selected a group of answers from the combo box, use those values
  1580.                                     If Request.Form("ItemAnswerGroupSelected") = SUR_BOOLEAN_POSITIVE Then
  1581.                                         strAnswerValue = ""
  1582.                                         Select Case i
  1583.                                             Case 1:
  1584.                                                 strValue = rsAnswers("answer_1")
  1585.                                             Case 2:
  1586.                                                 strValue = rsAnswers("answer_2")
  1587.                                             Case 3:
  1588.                                                 strValue = rsAnswers("answer_3")
  1589.                                             Case 4:
  1590.                                                 strValue = rsAnswers("answer_4")
  1591.                                             Case 5:
  1592.                                                 strValue = rsAnswers("answer_5")
  1593.                                         End Select
  1594.                                     ElseIf strState = SUR_STATE_INSERT Then
  1595.                                         'In INSERT mode, display the value previously entered, if it exists
  1596.                                         strValue = Request.Form("txtAnswer" & i)
  1597.                                         strAnswerValue = Request.Form("txtAnswerValue" & i)
  1598.                                     ElseIf strState = SUR_STATE_EDIT_REFRESH Or strState = SUR_STATE_INSERT_REFRESH Then
  1599.                                         strValue = Request.Form("txtAnswer" & i)
  1600.                                         strAnswerValue = Request.Form("txtAnswerValue" & i)
  1601.                                     Else 'EDIT mode
  1602.                                         'In EDIT mode, get the next answer that was previously recorded.  If there are no more
  1603.                                         'answers, simply display an empty string
  1604.                                         If Not rsAnswers.EOF Then
  1605.                                             strValue = rsAnswers("answer_text")
  1606.                                             strAnswerValue = rsAnswers("answer_value")
  1607.                                             strDefaultYN = rsAnswers("default_yn")
  1608.                                             rsAnswers.MoveNext
  1609.                                         Else
  1610.                                             'Default to no value if this is a potentially new entry
  1611.                                             strDefaultYN = SUR_BOOLEAN_NEGATIVE
  1612.                                             strValue = ""
  1613.                                             strAnswerValue = ""
  1614.                                         End If
  1615.                                     End If
  1616.  
  1617.                                     If IsNull(strValue) = True Then
  1618.                                         strValue = ""
  1619.                                     End If
  1620. %>
  1621.                                     <input type="text" style="width:325px" maxlength="255" value="<%=Server.HTMLEncode(strValue)%>" name="txtAnswer<%=i%>" id="txtAnswer<%=i%>">
  1622. <%
  1623.                                     'Display different controls next to each value depending on the control type
  1624.                                     Select Case CLng(lngComboItemTypeID)
  1625.                                         'Display radio buttons for single-select functionality
  1626.                                         Case SUR_ITEM_SINGLE_SELECT_DROPDOWN, SUR_ITEM_SINGLE_SELECT_OPTIONS:
  1627.                                             'Determine whether the default radio button should be selected or not selected
  1628.                                             strChecked = ""
  1629.                                             If strState = SUR_STATE_INSERT Or strState = SUR_STATE_INSERT_REFRESH Or strState = SUR_STATE_EDIT_REFRESH Then
  1630.                                                 If Request.Form("txtDefaultAnswerYN" & i) = "on" Then
  1631.                                                     strChecked = "checked"
  1632.                                                 End If
  1633.                                             Else 'EDIT mode
  1634.                                                 If strDefaultYN = SUR_BOOLEAN_POSITIVE Then
  1635.                                                     strChecked = "checked"
  1636.                                                 End If
  1637.                                             End If
  1638. %>
  1639.                                             <label for="txtDefaultAnswerYN"> </label> <input type="radio" <%=strChecked%> name="txtDefaultAnswerYN" id="txtDefaultAnswerYN" value="txtAnswer<%=i%>"><span class="InlineHelpSpanStyle">Default</span>
  1640. <%
  1641.                                         'Display check boxes for multi-select functionality
  1642.                                         Case SUR_ITEM_MULTISELECT_CHECKBOXES:
  1643.                                             'Determine whether the default checkbox should be set to checked or not
  1644.                                             strChecked = ""
  1645.                                             If strState = SUR_STATE_INSERT Or strState = SUR_STATE_INSERT_REFRESH Or strState = SUR_STATE_EDIT_REFRESH Then
  1646.                                                 If Request.Form("txtDefaultAnswerYN" & i) = "on" Then
  1647.                                                     strChecked = "checked"
  1648.                                                 End If
  1649.                                             Else 'EDIT mode
  1650.                                                 If strDefaultYN = SUR_BOOLEAN_POSITIVE Then
  1651.                                                     strChecked = "checked"
  1652.                                                 End If
  1653.                                             End If
  1654. %>
  1655.                                             <label for="txtDefaultAnswerYN<%=i%>"> </label> <input type="checkbox" <%=strChecked%> name="txtDefaultAnswerYN<%=i%>" id="txtDefaultAnswerYN<%=i%>"><span class="InlineHelpSpanStyle">Default</span>
  1656. <%
  1657.                                         Case Else:
  1658.                                             'Do not display anything for all other item types
  1659.                                     End Select
  1660.  
  1661.                                     'Only display the points input box for checkboxes, dropdowns, and option buttons
  1662.                                     If CLng(lngComboItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngComboItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Then
  1663. %>
  1664.                                         <label for="txtAnswerValue<%=i%>"> </label>  <input type="text" size="3" maxlength="3" value="<%=strAnswerValue%>" name="txtAnswerValue<%=i%>" id="txtAnswerValue<%=i%>"><span class="InlineHelpSpanStyle"> points</span>
  1665. <%
  1666.                                     End If
  1667. %>
  1668.                                 </td>
  1669.                             </tr>
  1670. <%
  1671.                         Next
  1672. %>
  1673.                         <tr>
  1674.                             <td> </td>
  1675.                             <td align="left">
  1676.                                 <table cellspacing="0" cellpadding="3" border="0" width="325">
  1677.                                     <tr>
  1678.                                         <td align="right">
  1679. <%
  1680.                                             'The heading of this section depends on the item type being displayed.
  1681.                                             If IsMatrixQuestion(lngComboItemTypeID) = True Then
  1682. %>
  1683.                                                 <a href="javascript:insertNewAnswer();"><img border="0" border="0" alt="Insert a new column" name="btnInsertNewAnswer" src="Resources/Buttons/InsertNewColumnSmall.gif"></a>
  1684. <%
  1685.                                             Else
  1686. %>
  1687.                                                 <a href="javascript:insertNewAnswer();"><img border="0" border="0" alt="Insert a new answer" name="btnInsertNewAnswer" src="Resources/Buttons/InsertNewAnswerSmall.gif"></a>
  1688. <%
  1689.                                             End If
  1690. %>
  1691.                                         </td>
  1692.                                     </tr>
  1693.                                 </table>
  1694.                             </td>
  1695.                         </tr>
  1696.                     </table>
  1697.                 </td>
  1698.             </tr>
  1699. <%
  1700.             If DisplayControl(SUR_CONTROL_OTHER, lngComboItemTypeID) = True Then
  1701. %>
  1702.                 <tr>
  1703.                     <td valign="top">
  1704.                         <table cellspacing="0" cellpadding="3" border="0" width="100%">
  1705.                             <tr>
  1706.                                 <td width="20" valign="top">
  1707.                                     <input type="checkbox" <% If strOtherYesNo = SUR_BOOLEAN_POSITIVE Then Response.Write "checked " End If %> name="chkOther" id="chkOther" style="vertical-align:top">
  1708.                                 </td>
  1709.                                 <td>
  1710.                                     <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="chkOther">Allow additional answer.</label></span> <label for="txtOther">Check this box if you would like an
  1711.                                         additional "Other" answer to allow survey takers to give a different answer.  You may edit the text of
  1712.                                         the "Other" prompt in the text box below.</label><br></span>
  1713.                                     <input type="text" name="txtOther" id="txtOther" value="<%=strOtherText%>" maxlength="150" size="48">
  1714.                                 </td>
  1715.                             </tr>
  1716.                             <tr>
  1717.                                 <td valign="top">
  1718.                                      
  1719.                                 </td>
  1720.                                 <td>
  1721.                                     <span class="InlineHelpSpanStyle"><span class="InlineHelpSpanStyleBold"><label for="cboOtherDisplayType">Additional answer input type.</label></span> Select the type
  1722.                                     of control that should be used to for the additional answer.<br></span>
  1723.                                     <select name="cboOtherDisplayType" id="cboOtherDisplayType" style="width:250px">
  1724.                                         <option <% If strOtherDisplayType = SUR_OTHER_DISPLAY_TYPE_TEXTAREA Then Response.Write "SELECTED" End If %> value="<%=SUR_OTHER_DISPLAY_TYPE_TEXTAREA%>"><%=SUR_OTHER_DISPLAY_TYPE_TEXTAREA%></option>
  1725.                                         <option <% If strOtherDisplayType = SUR_OTHER_DISPLAY_TYPE_TEXTBOX Then Response.Write "SELECTED" End If %> value="<%=SUR_OTHER_DISPLAY_TYPE_TEXTBOX%>"><%=SUR_OTHER_DISPLAY_TYPE_TEXTBOX%></option>
  1726.                                     </select>
  1727.                                 </td>
  1728.                             </tr>
  1729.                         </table>
  1730.                     </td>
  1731.                 </tr>
  1732. <%
  1733.             End If
  1734.         End If
  1735. %>
  1736.         <tr>
  1737.             <td valign="center" align="right" height="44">
  1738. <%
  1739.                 'Only display the Delete button if the item is in EDIT mode, and the survey does not have any responses
  1740.                 If (strState = SUR_STATE_EDIT Or strState = SUR_STATE_EDIT_REFRESH) And flgHasResponses = False Then
  1741. %>
  1742.                     <a href="javascript:deleteItem('<%=lngItemID%>', '<%=lngSurveyOrLibraryID%>', '<%=lngPageNumber%>');"><img border="0" border="0" alt="Delete this item" name="btnDelete" src="Resources/Buttons/Delete.gif"></a>
  1743. <%
  1744.                 End If
  1745.  
  1746.                 'Optinally link back to either the modify survey or modify library page
  1747.                 If Len(lngSurveyID) > 0 Then
  1748. %>
  1749.                     <a href="ModifySurvey.asp?SurveyID=<%=lngSurveyID%>&#ItemID<%=lngItemID%>"><img border="0" border="0" alt="Cancel" name="btnCancel" src="Resources/Buttons/Cancel.gif"></a>
  1750. <%
  1751.                 Else
  1752. %>
  1753.                     <a href="ModifyLibrary.asp?LibraryID=<%=lngLibraryID%>&#ItemID<%=lngItemID%>"><img border="0" border="0" alt="Cancel" name="btnCancel" src="Resources/Buttons/Cancel.gif"></a>
  1754. <%
  1755.                 End If
  1756.  
  1757.                 'Only display the Save button if the page is not in pure insert mode.  In pure insert mode, the user has
  1758.                 'only a combo box to select the question type from.
  1759.                 If strState <> SUR_STATE_INSERT Then
  1760. %>
  1761.                     <a href="javascript:submitCheck();"><img border="0" border="0" alt="Save" name="btnSave" src="Resources/Buttons/Save.gif"></a>
  1762. <%
  1763.                 End If
  1764. %>
  1765.             </td>
  1766.         </tr>
  1767.         <input type="hidden" name="AnswerCount" value="<%=lngAnswerCount%>">
  1768.     </form>
  1769. </table>
  1770.  
  1771. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  1772.  
  1773. </body>
  1774.  
  1775. <!-- This form is used to copy an existing item -->
  1776. <form action="CopyItem.asp" method="POST" name="frmCopyExistingItem">
  1777.     <input type="hidden" name="PageNumber" value="<%=Request.Form("PageNumber")%>">
  1778.     <input type="hidden" name="NewPage" value="<%=Request.Form("NewPage")%>">
  1779.     <input type="hidden" name="SurveyID" value="<%=Request.Form("SurveyID")%>">
  1780.     <input type="hidden" name="LibraryID" value="<%=lngLibraryID%>">
  1781.     <input type="hidden" name="SurveyName" value="<%=Request.Form("SurveyName")%>">
  1782.     <input type="hidden" name="State" value="<%=SUR_STATE_INSERT%>">
  1783.     <input type="hidden" name="OrderNumber" value="<%=Request.Form("OrderNumber")%>">
  1784. </form>
  1785.  
  1786. </html>
  1787. <%
  1788.     conItem.Close
  1789.     Set conItem = Nothing
  1790.  
  1791.     'Ensure that the web server returns the page
  1792.     Response.Flush
  1793.  
  1794.     '*****************************************************************************************
  1795.     ' Name:         DisplayControl
  1796.     ' Purpose:      This function is called through out the page to determine which sections of the
  1797.     '                page should be displayed, based on the item type selected.
  1798.     '
  1799.     '                The behavior of this function may seem counter-intuitive at first, as it
  1800.     '                assumes False (do not display) and then sets to true any case where the
  1801.     '                combination should be displayed.  Therefore, for any control type that SHOULD be
  1802.     '                displayed, make sure to include any entry that sets the return value to True
  1803.     '                under each item type ID where it should be displayed.
  1804.     '
  1805.     ' Arguments:    strControlName -- The name of the control, which may optionally be displayed on this screen
  1806.     '                lngComboItemTypeID - The item type ID being displayed
  1807.     '
  1808.     ' Return Value: flgReturnValue -- A flag indicating whether or not to display the control
  1809.     ' Notes:
  1810.     '*****************************************************************************************
  1811.     Function DisplayControl(strControlName, lngComboItemTypeID)
  1812.         Dim flgReturnValue
  1813.  
  1814.         flgReturnValue = False
  1815.  
  1816.         Select Case CLng(lngComboItemTypeID)
  1817.             Case SUR_ITEM_HORIZONTAL_RULE:
  1818.             Case SUR_ITEM_IMAGE:
  1819.                 If strControlName = SUR_CONTROL_HAS_OPTIONS Then
  1820.                     flgReturnValue = True
  1821.                 End If
  1822.             Case SUR_ITEM_HEADING:
  1823.                 If strControlName = SUR_CONTROL_QUESTION Then
  1824.                     flgReturnValue = True
  1825.                 End If
  1826.             Case SUR_ITEM_MESSAGE:
  1827.                 If strControlName = SUR_CONTROL_QUESTION Then
  1828.                     flgReturnValue = True
  1829.                 End If
  1830.             Case SUR_ITEM_HTML:
  1831.                 If strControlName = SUR_CONTROL_QUESTION Then
  1832.                     flgReturnValue = True
  1833.                 End If
  1834.             Case SUR_ITEM_SINGLE_SELECT_DROPDOWN:
  1835.                 If strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_ANSWER Or strControlName = SUR_CONTROL_REQUIRED Then
  1836.                     flgReturnValue = True
  1837.                 End If
  1838.             Case SUR_ITEM_SINGLE_SELECT_OPTIONS:
  1839.                 If strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_ANSWER Or strControlName = SUR_CONTROL_REQUIRED Or strControlName = SUR_CONTROL_OTHER Then
  1840.                     flgReturnValue = True
  1841.                 End If
  1842.             Case SUR_ITEM_MULTISELECT_CHECKBOXES:
  1843.                 If strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_ANSWER Or strControlName = SUR_CONTROL_OTHER Or strControlName = SUR_CONTROL_REQUIRED Then
  1844.                     flgReturnValue = True
  1845.                 End If
  1846.             Case SUR_ITEM_OPEN_ENDED_ONE_LINE:
  1847.                 If strControlName = SUR_CONTROL_MAXIMUM_LENGTH Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1848.                     flgReturnValue = True
  1849.                 End If
  1850.             Case SUR_ITEM_DATABASE_DROPDOWN:
  1851.                 If strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1852.                     flgReturnValue = True
  1853.                 End If
  1854.             Case SUR_ITEM_OPEN_ENDED_COMMENTS_BOX:
  1855.                 If strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1856.                     flgReturnValue = True
  1857.                 End If
  1858.             Case SUR_ITEM_DATE:
  1859.                 If strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1860.                     flgReturnValue = True
  1861.                 End If
  1862.             Case SUR_ITEM_NUMBER:
  1863.                 If strControlName = SUR_CONTROL_MAXIMUM_LENGTH Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1864.                     flgReturnValue = True
  1865.                 End If
  1866.             Case SUR_ITEM_YES_NO, SUR_ITEM_TRUE_FALSE:
  1867.                 If strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1868.                     flgReturnValue = True
  1869.                 End If
  1870.             Case SUR_ITEM_CONSTANT_SUM
  1871.                 If strControlName = SUR_CONTROL_ROW_TEXT_WIDTH Or strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_ROWS Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1872.                     flgReturnValue = True
  1873.                 End If
  1874.             Case SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES
  1875.                 If strControlName = SUR_CONTROL_ROW_TEXT_WIDTH Or strControlName = SUR_CONTROL_MAXIMUM_LENGTH Or strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_ROWS Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1876.                     flgReturnValue = True
  1877.                 End If
  1878.             Case SUR_ITEM_RANKING
  1879.                 If strControlName = SUR_CONTROL_ROW_TEXT_WIDTH Or strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_ROWS Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1880.                     flgReturnValue = True
  1881.                 End If
  1882.             Case SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS, SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES, SUR_ITEM_MATRIX_TEXT_BOXES
  1883.                 If strControlName = SUR_CONTROL_ROW_TEXT_WIDTH Or strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_ROWS Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_ANSWER Or strControlName = SUR_CONTROL_REQUIRED Then
  1884.                     flgReturnValue = True
  1885.                 End If
  1886.             Case SUR_ITEM_MATRIX_RATING_SCALE
  1887.                 If strControlName = SUR_CONTROL_ROW_TEXT_WIDTH Or strControlName = SUR_CONTROL_RANDOM_ORDER Or strControlName = SUR_CONTROL_ROWS Or strControlName = SUR_CONTROL_HAS_OPTIONS Or strControlName = SUR_CONTROL_QUESTION Or strControlName = SUR_CONTROL_REQUIRED Then
  1888.                     flgReturnValue = True
  1889.                 End If
  1890.         End Select
  1891.  
  1892.         DisplayControl = flgReturnValue
  1893.     End Function
  1894.  
  1895.     '*****************************************************************************************
  1896.     ' Name:         IsMatrixQuestion
  1897.     ' Purpose:      This function returns a boolean indicating whether or not the specified item type
  1898.     '                is a matrix question.  The purpose of this function is simply to shorten and clean
  1899.     '                up the code.
  1900.     '
  1901.     ' Arguments:    lngItemTypeID - The item type ID being displayed
  1902.     '
  1903.     ' Return Value: flgReturnValue -- A flag indicating whether or not the item is a matrix
  1904.     '
  1905.     '*****************************************************************************************
  1906.     Function IsMatrixQuestion(lngItemTypeID)
  1907.  
  1908.         Dim flgReturnValue
  1909.  
  1910.         If CLng(lngItemTypeID) = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or CLng(lngItemTypeID) = SUR_ITEM_MATRIX_RATING_SCALE Or CLng(lngItemTypeID) = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or CLng(lngItemTypeID) = SUR_ITEM_MATRIX_TEXT_BOXES Then
  1911.             flgReturnValue = True
  1912.         Else
  1913.             flgReturnValue = False
  1914.         End If
  1915.  
  1916.         IsMatrixQuestion = flgReturnValue
  1917.  
  1918.     End Function
  1919. %>
  1920.