JS 2 단 연동 다 중 선택 상자


  
  
  
  
  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. } 
  19. } 
  20. } 
  21. if (found != true) { 
  22. destList.options[len] = new Option(srcList.options[i].text); 
  23. len++; 
  24. } 
  25. } 
  26. } 
  27. } 
  28. function deleteFromDestList() { 
  29. var destList = window.document.forms[0].destList; 
  30. var len = destList.options.length; 
  31. for(var i = (len-1); i >= 0; i--) { 
  32. if ((destList.options[i] != null) && (destList.options[i].selected == true)) { 
  33. destList.options[i] = null; 
  34. } 
  35. } 
  36. } 
  37.  
  38. var array=new Array(); 
  39. array[0]='<option value=" "> </option><option value=" "> </option>' 
  40. array[1]='<option value=" "> </option>' 
  41. array[2]='<option value=" "> </option>' 
  42. array[3]='<option value=" "> </option><option value=" "> </option>' 
  43.  
  44. function change(w){ 
  45.  str='<select style="width:100;font-size:13px" size="5" name="srcList" multiple onchange="javascript:addSrcToDestList()">'  
  46.  str+=array[w] 
  47.  str+='</select>' 
  48.     sList.innerHTML=str 
  49. } 
  50. </SCRIPT> 
  51. </head> 
  52.  
  53. <body> 
  54. <center> 
  55. <form method="POST"> 
  56. <table bgcolor="#FFFFCC"> 
  57. <tr> 
  58. <td align="center"> 
  59. : 
  60. </td> 
  61. <td> 
  62. : 
  63. </td> 
  64. </tr> 
  65. <tr> 
  66. <td bgcolor="#FFFFCC" width="400"> 
  67. <select style='width:100;font-size:13px' id="subList" size="5" name="subList" multiple onchange="javascript:change(subList.value);event.cancelBubble=true;return false"> 
  68. <option value="0"> </option> 
  69. <option value="1"> </option> 
  70. <option value="2"> </option> 
  71. <option value="3"> </option> 
  72. <option value="4"> </option> 
  73. <option value="5"> </option> 
  74. </select> 
  75. <span id="sList"> 
  76. <select style='width:100;font-size:13px' size="5" name="srcList" multiple onchange="javascript:addSrcToDestList()"> 
  77. </select> 
  78. </span> 
  79. </td> 
  80. <td bgcolor="#FFFFCC" width="69"> 
  81. <select style='width:100;font-size:13px' size="5" name="destList" multiple> 
  82. </select> 
  83. </td> 
  84. </tr> 
  85. <tr> 
  86. <td colspan="3" align="center">&nbsp; 
  87. </td> 
  88. </tr> 
  89. <tr> 
  90. <td align="center"> 
  91. <input type="button" value="   " onclick=""> 
  92. </td> 
  93. <td> 
  94. <input type="button" value="   " onclick="javascript:deleteFromDestList();"> 
  95. </td> 
  96. </tr> 
  97. </table> 
  98. </form> 
  99. </body> 
  100. </html> 

좋은 웹페이지 즐겨찾기