JS二級聯動多選框

 

  
  
           
  
  
  1. <html> 
  2. <head> 
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
  4. <script language="JavaScript"> 
  5. <!-- 
  6. function addSrcToDestList() { 
  7. destList = window.document.forms[0].destList; 
  8. srcList = window.document.forms[0].srcList; 
  9. var len = destList.length; 
  10. for(var i = 0; i < srcList.length; i++) { 
  11. if ((srcList.options[i] != null) && (srcList.options[i].selected)) { 
  12. var found = false
  13. for(var count = 0; count < len; count++) { 
  14. if (destList.options[count] != null) { 
  15. if (srcList.options[i].text == destList.options[count].text) { 
  16. found = true
  17. break; 
  18. if (found != true) { 
  19. destList.options[len] = new Option(srcList.options[i].text); 
  20. len++; 
  21. function deleteFromDestList() { 
  22. var destList = window.document.forms[0].destList; 
  23. var len = destList.options.length; 
  24. for(var i = (len-1); i >= 0; i--) { 
  25. if ((destList.options[i] != null) && (destList.options[i].selected == true)) { 
  26. destList.options[i] = null; 
  27.  
  28. var array=new Array(); 
  29. array[0]='<option value="系統管理員">系統管理員</option><option value="安檢科採煤科長">安檢科採煤科長</option>
  30. array[1]='<option value="安檢科科長">安檢科科長</option>
  31. array[2]='<option value="安裝隊責任人">安裝隊責任人</option>
  32. array[3]='<option value="供應科內業科長">供應科內業科長</option><option value="機電科科長">機電科科長</option>
  33.  
  34. function change(w){ 
  35.  str='<select style="width:100;font-size:13px" size="5" name="srcList" multiple onchange="javascript:addSrcToDestList()">'  
  36.  str+=array[w] 
  37.  str+='</select>
  38.     sList.innerHTML=str 
  39. </SCRIPT> 
  40. </head> 
  41.  
  42. <body> 
  43. <center> 
  44. <form method="POST"> 
  45. <table bgcolor="#FFFFCC"> 
  46. <tr> 
  47. <td align="center"> 
  48. 收件人列表: 
  49. </td> 
  50. <td> 
  51. 已選收件人: 
  52. </td> 
  53. </tr> 
  54. <tr> 
  55. <td bgcolor="#FFFFCC" width="400"> 
  56. <select style='width:100;font-size:13px' id="subList" size="5" name="subList" multiple onchange="javascript:change(subList.value);event.cancelBubble=true;return false"> 
  57. <option value="0">安檢科</option> 
  58. <option value="1">調度室</option> 
  59. <option value="2">培訓科</option> 
  60. <option value="3">生產科</option> 
  61. <option value="4">巷修二隊</option> 
  62. <option value="5">財務科</option> 
  63. </select> 
  64. <span id="sList"> 
  65. <select style='width:100;font-size:13px' size="5" name="srcList" multiple onchange="javascript:addSrcToDestList()"> 
  66. </select> 
  67. </span> 
  68. </td> 
  69. <td bgcolor="#FFFFCC" width="69"> 
  70. <select style='width:100;font-size:13px' size="5" name="destList" multiple> 
  71. </select> 
  72. </td> 
  73. </tr> 
  74. <tr> 
  75. <td colspan="3" align="center">&nbsp; 
  76. </td> 
  77. </tr> 
  78. <tr> 
  79. <td align="center"> 
  80. <input type="button" value=" 肯定 " onclick=""> 
  81. </td> 
  82. <td> 
  83. <input type="button" value=" 從右邊刪除 " onclick="javascript:deleteFromDestList();"> 
  84. </td> 
  85. </tr> 
  86. </table> 
  87. </form> 
  88. </body> 
  89. </html>
相關文章
相關標籤/搜索