<html>
<head>
<title></title> 
<script>
function move(oSrc,oDest){
  for(var i=0;i<oSrc.options.length;i++){
    oDest.options[oDest.options.length] = new Option(oSrc.options[i].text,oSrc.options[i].value);
  }
  oSrc.options.length = 0;
}
</script>
</head>
<body>
<form>
<select id="a" size="10">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input type="button" value=">>" onclick="move(document.all.a,document.all.b);">
<input type="button" value="<<" onclick="move(document.all.b,document.all.a);">
<select id="b" size="10">
</select>
</form>
</body>
</html>

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>将select3的所有值复制到select4中</title>
    <script language="javascript">
    function copydata()
    {
    var i=0;
    for (i==0;i<document.form1.select3.length;i++)
    {
    document.form1.select4.options[i]=new Option(document.form1.select3.options[i].value,document.form1.select3.options[i].desc);
    }
    }
    </script>
    </head><body>
    <table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
    <form name="form1" method="post" action="">
      <tr>
        <td>
          <select name="select3" size="5" id="select3">
            <option value="项目1">项目1</option>
            <option value="项目2">项目2</option>
            <option value="项目3">项目3</option>
            <option value="项目4">项目4</option>
            <option value="项目5">项目5</option>
          </select>
        </td>
        <td><input name="button1" type="button" id="button1" value="添加到select4" onClick="copydata();"></td>
        <td><select name="select4" size="5" id="select4">
                </select></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </form>
    </table>
    </body>
    </html>