JavaScript 複選multiple 左右資料移轉

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
/* textareaChange(select FromtID, select ToID, string Cmd)
 * FromtID 來源元件
 * ToID 目的元件
 * Cmd A:全部來源資料到目的
 */
function textareaChange(FromtID, ToID, Cmd)
{
 alert( document.getElementById(FromtID).options.length);
 for(var i = 0 ; i < document.getElementById(FromtID).options.length  ; i++)
 {
  if(Cmd == "A" | document.getElementById(FromtID)[i].selected)
  {
   document.getElementById(ToID).options.add(
    new Option(
     document.getElementById(FromtID)[i].text,
     document.getElementById(FromtID)[i].value));
   document.getElementById(FromtID).remove(i);
  }
 }
}
</script>
<title>textareaChange</title>
</head>
<body>
<table width="200" border="0" align="center">
  <tr>
    <td>
        <select name="LS_L" size="5" multiple="multiple" id="LS_L">
          <option value="ABC">ABC</option>
          <option value="DEF">DEF</option>
          <option value="GHI">GHI</option>
        </select>
    </td>
    <td>
        <input name="IP_in" type="button" value=" >"
            onclick="textareaChange('LS_L','LS_R','');" /><br />
        <input name="IP_allin" type="button" value=">>"
            onclick="textareaChange('LS_L','LS_R','A');" /><br /><br />
        <input name="IP_out" type="button" value=" <"
            onclick="textareaChange('LS_R','LS_L','');"><br />
        <input name="IP_allout" type="button" value="<<"
            onclick="textareaChange('LS_R','LS_L','A');"/><br />
    </td>
    <td>
        <select name="LS_R" size="5" multiple="multiple" id="LS_R">
          <option value="123">123</option>
          <option value="456">456</option>
          <option value="789">789</option>
        </select>   
    </td>
  </tr>
</table>
</body>
</html>

留言

這個網誌中的熱門文章

delivery note和delivery order的區別和翻譯

Eclipse 3.6.1 Helios 中文化方法

牙技專業英文--技工篇