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>
相关文章
相关标签/搜索