Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.6 KiB

  1. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  2. <script language=javascript>
  3. //------------------------------------------------------------------------
  4. //
  5. // inc_MasterWeb.js: Resuable JavaScript functions
  6. // used accross all the pages
  7. //
  8. // Copyright (c) Microsoft Corporation. All rights reserved.
  9. //
  10. // Date Description
  11. // 30/10/2000 Creation date
  12. //------------------------------------------------------------------------
  13. // Local variables
  14. var flag="false";
  15. //------------------------------------------------------------------------
  16. // Function to clear the error messages (if any on screen) whenever required
  17. //------------------------------------------------------------------------
  18. function ClearErr()
  19. {
  20. // checking for the browser type
  21. if (IsIE())
  22. {
  23. document.all("divErrMsg").innerHTML = "";
  24. // removing the event handling
  25. document.frmTask.onkeypress = null;
  26. }
  27. }
  28. //------------------------------------------------------------------------
  29. // Function: addToListBox
  30. // Description: moves the passed textbox value to ListBox
  31. // input: objList-List Object
  32. // : ButtonObject- Remove button
  33. // : strText-Text of the option item
  34. // : strValue-value of the option item
  35. // output: btnRemove-Button
  36. //------------------------------------------------------------------------
  37. function addToListBox(objList,btnRemove,strText,strValue)
  38. {
  39. var blnResult=true;
  40. // checking for the text value null
  41. // If the value passed is null make it as text
  42. if (strValue=="")
  43. {
  44. strValue=strText;
  45. }
  46. if (strText!="" )
  47. {
  48. // check for duplicates not required as duplicates accepted
  49. if (!chkDuplicate(objList,strText))
  50. {
  51. // create a new option in the list box
  52. objList.options[objList.length] = new Option(strText,strValue);
  53. objList.options[objList.length-1].selected = true;
  54. // enable the Remove button
  55. if(btnRemove.disabled)
  56. btnRemove.disabled = false ;
  57. }
  58. else
  59. {
  60. blnResult= false;
  61. }
  62. }
  63. else
  64. {
  65. blnResult= false;
  66. }
  67. return blnResult;
  68. }
  69. //------------------------------------------------------------------------
  70. // Function: chkDuplicate
  71. // Description: checks for the duplicate text in the list box
  72. // input: Object -Radio Object
  73. // : strchkName -value of the Name to be checked
  74. //returns: blnDuplicate-Returns true/false on success/failure
  75. //------------------------------------------------------------------------
  76. function chkDuplicate(objList,strchkName)
  77. {
  78. var i;
  79. var blnDuplicate=false;
  80. for(var i=0;i < objList.length;i++)
  81. {
  82. if (objList.options[i].text == strchkName)
  83. blnDuplicate = true;
  84. }
  85. return blnDuplicate;
  86. }
  87. //------------------------------------------------------------------------
  88. // Function: remFromListBox
  89. // Description: Removes the passed textbox value from ListBox
  90. // input: objList-List Object
  91. // : ButtonObject- Remove button
  92. // : strText-Text of the option item
  93. //------------------------------------------------------------------------
  94. function remFromListBox(objList,strText)
  95. {
  96. var blnResult=true;
  97. var remPos;
  98. // checking for the text value null
  99. if (strText!="" )
  100. {
  101. // Remove the option from the list box
  102. remPos = objList.selectedIndex;
  103. if(remPos >= 0)
  104. objList.options[remPos]=null;
  105. }
  106. else
  107. {
  108. blnResult= false;
  109. }
  110. return blnResult;
  111. }
  112. //------------------------------------------------------------------------
  113. // Function : AddRemoveListBoxItems
  114. // Description: To Add or remove all the options from the given list
  115. // Input: objList -Listbox
  116. // Returns:
  117. // Support functions used : ClearErr
  118. //------------------------------------------------------------------------
  119. function AddRemoveListBoxItems(objListAdd, objListRem)
  120. {
  121. // Clear any previous error messages
  122. ClearErr();
  123. var i=0,j;
  124. // number of elements in the list object
  125. var intListLength = objListRem.length;
  126. j = objListAdd.length;
  127. while(intListLength > 0)
  128. {
  129. if(!chkDuplicate(objListAdd,objListRem.options[i].value))
  130. {
  131. objListAdd.options[j] = new Option(objListRem.options[i].value,objListRem.options[i].value);
  132. }
  133. objListRem.options[i].value = null;
  134. j++;i++;
  135. intListLength--;
  136. }
  137. intListLength = 0;i=0;
  138. intListLength = objListRem.length;
  139. while(i<=intListLength){
  140. objListRem.options[i] = null;
  141. intListLength--;}
  142. }
  143. </script>