在一个select选择框中选一个东西在另一个框中显示出来
请问我为什么选一个东西后点击确定,在另一个框中无法显示,是否有错误代码,请高手帮我看下谢谢
<script language=JavaScript>
function createoptions()
{
   sel1=document.form1.select1;
   sel2=document.form1.select2;
   var num=sel1.selectedIndex;
  if(num>1){
    var option=new option(sell.options[mun].text);
    var item=sel2.options.length;
   sel2.options[item]=option;
          }
   sel1.selectedIndex=10000;
}</script>
<form name="form1">
<select name="select1" size="10"ondblclick="createoptions()">
<option>可选择的项目
<option>------------
<option type="香蕉">香蕉</option>
<option type="番茄">番茄</option>
<option type="土豆">土豆</option>
<option type="草莓">草莓</option>
</select>
<input type="button" value="确定" onclick="createoptions()">
<select name="select2" size="10">
<option>选择项目
<option>------------
</select>
<input type="button" value="删除" onclick="deloptions()">
<input type="button" value="全部删除" onclick="delalloptions()">
</form>

解决方案 »

  1.   

    /***************************************************************
     * 文件名:setMovelist.js
     * 功能描述:两个列表中列表项的交互移动
     * 页面命名限制:表单名(formst)、列表名(first\last)
     * 作者:***
     * 创建日期:2006.2.28
     * 修改日期:
    ****************************************************************/

    function addAttri()
    {//移动选择项first->last
    var objform=document.formst;
    if(objform==null)
    {
    return false;
    }
    var objmenu1=document.formst.first;
    var objmenu2=document.formst.last;
    var optionresult=objmenu1.options;
    var option;
    for( var i=optionresult.length;i>=0;i--)
    {
    option=optionresult[i];
    if(option!=null)
    {
    if(option.selected)
    {
    objmenu1.remove(option.index);
    objmenu2.add(option);
    }
    }
    }
    }
    function remAttri()
    {//移动选择项last->first
    var objform=document.formst;
    if(objform==null)
    {
    return false;
    }
    var firstoption=objform.first;
    var lastoption =objform.last;
    var selectoption=lastoption.options;
    var selecto;
    for(var i=selectoption.length;i>=0;i--)
    {
    selecto=selectoption[i];
    if(selecto!=null)
    {
    if(selecto.selected)
    {
    lastoption.remove(selecto.index);
    firstoption.add(selecto);
    }
    }
    }
    }
    function addall()
    {//移动全部项first->last
    var objform=document.formst;
    if(objform==null)
    {
    return false;
    }
    var firstoption=objform.first;
    var lastoption =objform.last;
    if(firstoption==null)return false;
    if(lastoption ==null)return false;
    var optionfirst=firstoption.options;
    var lastoption =lastoption.options;
    var option;
    for(var i=optionfirst.length;i>=0;i--)
    {
    option=optionfirst[i];
    if(option!=null)
    {
    optionfirst.remove(option.index);
    lastoption.add(option);
    }
    }
    }
    function rmall()
    {//移动全部项last->first
    var objform=document.formst;
    if(objform==null)
    {
    return false;
    }
    var firstoption=objform.first;
    var lastoption =objform.last;
    if(firstoption==null)return false;
    if(lastoption ==null)return false;
    var optionfirst=firstoption.options;
    var lastoption =lastoption.options;
    var option;
    for(var i=lastoption.length;i>=0;i--)
    {
    option=lastoption[i];
    if(option!=null)
    {
    lastoption.remove(option.index);
    optionfirst.add(option);
    }
    }

    }这个是我n年前写的一个看看是否对你有帮助
      

  2.   

    <div>
    <select id="select1" size="20">
        <option>可以选择的水果</option>
        <option>--------------</option>
        <option value="大香蕉">香蕉</option>
        <option value="大苹果">苹果</option>
        <option value="大橘子">橘子</option>
        <option value="大火龙果">火龙果</option>
    </select><input type="button" value=" >> " onclick="add()">
    <input type="button" value=" << " onclick="del()"><select id="select2" size="20">
        <option>可以选择的水果</option>
        <option>--------------</option>
    </select>
    <script language="javascript">
    function add(){   
        var select_index = select1.selectedIndex;    if(select_index > 1){
            var option = document.createElement("option");
            option.value = select1.options[select_index].value;
            option.innerHTML = select1.options[select_index].innerHTML;
            select2.appendChild(option);
            select1.options[select_index] = null;
        }
    } var select1 = document.getElementById("select1");
        var select2 = document.getElementById("select2");function del(){
        var select_index = select2.selectedIndex;
        
        if(select_index > 1){
            var option = document.createElement("option");
            option.value = select2.options[select_index].value;
            option.innerHTML = select2.options[select_index].innerHTML;
            select1.appendChild(option);
            select2.options[select_index] = null;
        }
    }
    </script>
    </div>
      

  3.   

    我想请问你现在多大了,你的年龄>N,我发现你有装B的嫌疑