给你一个例子
你就明白了
<!--start
//midd 列表框选项对应right列表框选像的移动
//向右侧列表框添加选项
//当树型菜单的相应选型被selected时,传出一个变量(0 - 4 五个数中的一个)来判断相应的列表框
//number 这个变量需要接受的参数是字符串!!("1","2",....,"5")
function add_list_table(number)
{

var num=0;
var array = new Array();
array[0]=document.form1.rightone;
array[1]=document.form1.righttwo;
array[2]=document.form1.rightthree;
array[3]=document.form1.rightfour;
array[4]=document.form1.rightfive;
for(var n=0;n<5;n++)
{
if(n==number)
{
num=array[n];
}
}

    var ln = document.form1.middle.options.length;
for(var i = 0;i<ln;i++)
{
if(document.form1.middle.options[i].selected)
{
var yanzheng = true;
for(var m=0;m<num.options.length;m++)
{
if(document.form1.middle.options[i].innerText==num[m].innerText)
yanzheng = false;
}
if(yanzheng)
{
num.options.length++;
num[num.options.length-1].innerText=document.form1.middle.options[i].innerText;
num[num.options.length-1].value = num.options.length;
}
else
{
alert("yi jing chun zai");
}
 }
}
}
//--------------------------------------------------------------------------------------------------
//从右侧列表框删除选项
//当五个列表框中需要删除的选项被选中后,鼠标右键或者页面按钮触发该事件。
function del_list_table()
{
var array = new Array();
array[0]=document.form1.rightone;
array[1]=document.form1.righttwo;
array[2]=document.form1.rightthree;
array[3]=document.form1.rightfour;
array[4]=document.form1.rightfive;
for(var i=0;i<5;i++)
{
for(var j=0;j<array[i].options.length;j++)
{
if(array[i].options[j].selected)
{
array[i].options.removeChild(array[i].options[j]);
if(array[i].options.length!=0)array[i].options.length--;
}
}
for(var j=0;j<array[i].options.length;j++)
{
if(array[i].options[j].selected)
{
array[i].options.removeChild(array[i].options[j]);
}
}
}
}
//end -->

解决方案 »

  1.   

    是不是这样的效果??
    <table border=0 cellpadding=0 cellspacing=0><form name=meizz>
      <tr><td>
        <select id=list1 size=8 ondblclick="moveOption(this, this.form.list2)">
          <option value=A>aaaaaaaaaa
          <option value=B>bbbbbbbbbb
          <option value=C>cccccccccc
          <option value=D>dddddddddd
          <option value=E>eeeeeeeeee
          <option value=F>ffffffffff
          <option value=G>gggggggggg
          <option value=H>hhhhhhhhhh
        </select></td>
      <td width=40 align=center>
        <input name=add type=button value=">>>" onclick="moveOption(this.form.list1, this.form.list2)"><br><br>
        <input name=sub type=button value="<<<" onclick="moveOption(this.form.list2, this.form.list1)">
      </td><td>
        <select id=list2 size=8 ondblclick="moveOption(this, this.form.list1)">
        </select>
      </td></tr></form>
    </table><script language="JavaScript"><!--
    function moveOption(e1, e2){
        try{
            var e = e1.options[e1.selectedIndex];
            e2.options.add(new Option(e.text, e.value));
            e1.options.remove(e1.selectedIndex);
        }   catch(e){}
    }
    //--></script>