<script>
function test(o)
{
var a = new Option("AAA" + (new Date()).valueOf(),"aaa")
o.sel.options[o.sel.options.length] = a
}
</script>
<form name=f>
<select name=sel>
</select>
<input type=button onclick="test(this.form)" value="add">
</forM>

解决方案 »

  1.   

    var oOption = document.createElement("OPTION");
    oOption.text = "new";
    oOption.value="new";
    oList.options.add(oOption);
      

  2.   

    <script>
    myarray=new Array();
    function myset()
    {
    for(i=0;i<document.all.addrbook.length;i++)
    myarray[i]=0;
    }
    function myadd()
    {
    if(addrbook.selectedIndex>=0)
    {
    if(myarray[addrbook.selectedIndex]==0)
    {
    document.all.sendlist.length++
    document.all.sendlist.options[document.all.sendlist.length-1].text=document.all.addrbook.options[document.all.addrbook.selectedIndex].text;
    document.all.sendlist.options[document.all.sendlist.length-1].value=document.all.addrbook.options[document.all.addrbook.selectedIndex].value;
    document.all.addrbook.options[document.all.addrbook.selectedIndex].disabled=true;
    myarray[addrbook.selectedIndex]=1;
    }
    }
    }
    </script>
    <body onload=myset()>
    <select name=addrbook onchange=myadd() size=3>
    <option value=1>1
    <option value=12>12
    <option value=13>13
    </select>
    <select name=sendlist size=3>
    </select>
    <input type=button onclick=addsel()>