<select id=S></select>
<script>
function Add()
{
    document.all.S.length=10;
    var iCount=document.all.S.length;
    for(iIndex=0;iIndex<iCount;iIndex++)
    {
        document.all.S.options[iIndex].value=iIndex+"值";
        document.all.S.options[iIndex].text=iIndex+"项";
    }
}
function Clear()
{
    document.all.S.length=0;
}
</script>

解决方案 »

  1.   

    给你个例子,包括了所有你要的东西,就不知道你能不能消化。<script language=javascript>
    function moveOption(oSource,oTarget,bNotAlert)
    //参数依次为源下拉框、目标下拉框、无选项时是否不弹出警告。
    {
      if(oSource.selectedIndex==-1)  //如果没有选择的项
      {
        if(!bNotAlert)  //没有选择源下拉框中的项则弹出警告
          alert("你首先在源下拉框中选择一项然后才能进行操作!");
        return;  //直到没有选择的项时,结束递归。
      }
      var newOption=new Option(oSource.options[oSource.selectedIndex].text,oSource.options[oSource.selectedIndex].value);  //“复制”一份源下拉框中要“移动”的选项,即源下拉框中第一个选择的项。
      oTarget.options.add(newOption);  //把“复制”的选项“移”到目标下拉框
      oSource.options.remove(oSource.selectedIndex);  //删除源下拉框中选择的项
      newOption.selected=true;  //设置“移动”过去的项为选中状态
      moveOption(oSource,oTarget,1);  //递归,移动下一个源下拉框中选择的项。
    }
    </script><!-- 下面是应用实例 -->
    <select multiple size=6 id=slt1>
    <option value=1>Web技术中文网</option>
    <option value=2>Web技术中文论坛</option>
    <option value=3>Web技术中文杂志</option>
    <option value=4>IECN.net</option>
    <option value=5>IECN在线工具</option>
    <option value=6>www.iecn.net</option>
    </select> 
    <button onclick="moveOption(slt2,slt1)"><- </button>
    <button onclick="moveOption(slt1,slt2)"> -></button>
    <select multiple size=6 id=slt2></select>
    <br><br>
    鼠标拖动或按Ctrl/Shift键用鼠标选取可进行多选。