你那一二三是什么哦。
你可以在onload的时候,init你的select。默认select为空,然后init进去,你指定的数据

解决方案 »

  1.   

    <script language="javascript">
    function adduser()
        {
        freelength = document.all.freeid.length;
        for (var i=freelength-1;i>=0;i--)
            {
            if (document.all.freeid.options[i].selected)
                {
                var newtext = document.all.freeid.options[i].text;
                var newvalue = document.all.freeid.options[i].value;
                var nowlength = document.all.nowid.length;
                document.all.nowid.options[nowlength] = new Option(newtext,newvalue);
                document.all.freeid.options[i] = null;
                }
            }
        }
    function adduser2()
        {
        freelength = document.all.freeid.length;
        for (var i=freelength-1;i>=0;i--)
            {
          
                var newtext = document.all.freeid.options[i].text;
                var newvalue = document.all.freeid.options[i].value;
                var nowlength = document.all.nowid.length;
                document.all.nowid.options[nowlength] = new Option(newtext,newvalue);
                //document.all.freeid.options[i] = null;
              
            }
        }
    function deluser()
        {
        nowlength = document.all.nowid.length;
        for (var i=nowlength-1;i>=0;i--)
            {
            if (document.all.nowid.options[i].selected)
                {
                var newtext = document.all.nowid.options[i].text;
                var newvalue = document.all.nowid.options[i].value;
                var freelength = document.all.freeid.length;
                document.all.freeid.options[freelength] = new Option(newtext,newvalue);
                document.all.nowid.options[i] = null;
                }
            }
        }
    </script>
    </HEAD>
    <BODY BGCOLOR="#ffffff"  onload="adduser2()">
                <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#CCCCCC" width="100%">
                  <tr>
                    <td colspan="2">
                      <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
                        <tr>
                            <td>
                            <select name="freeid" multiple size="6" style="width:200px">
                            
                                <option value="1">admin</option>
                                <option value="2">dfdf</option>
                                <option value="3">ddfdffdf</option>
                                <option value="4">ddfdffdf</option>
                                <option value="5">ddfdffdf</option>                        </select>
                            </td>
                            <td valign="center" align="center">
                            <input type="button" class="it" value="添加>>" onclick="adduser()"><br/><br/>
                            <input type="button" class="it" value="<<删除" onclick="deluser()">
                            </td>
                            <td>
                            <select name="nowid" multiple size="6" style="width:200px">
                            
                                <option value="11">EHLDCIO</option>
                            
                                <option value="15">wanglifeng</option>
                            
                                <option value="16">service</option>
                            
                            </select>
                            </td>
                        </tr>
                      </table>
    </BODY>
      

  2.   

    to net_lover(孟子E章):
    不是把右边所有的加进去,只是部分数据,而且加在了右边后,左边就不出现了
      

  3.   

    你是不是,将左边的添加到右边后,刷新后,想让已经添加过去的,就在右边显示???
    这样的话,用cookie。
      

  4.   

    我修改一楼的代码如下:
    <script language="javascript">
    function adduser()
        {
        freelength = document.all.freeid.length;
        for (var i=freelength-1;i>=0;i--)
            {
            if (document.all.freeid.options[i].selected)
                {
                var newtext = document.all.freeid.options[i].text;
                var newvalue = document.all.freeid.options[i].value;
                var nowlength = document.all.nowid.length;
                document.all.nowid.options[nowlength] = new Option(newtext,newvalue);
                document.all.freeid.options[i] = null;
                }
            }
        }function deluser()
        {
        nowlength = document.all.nowid.length;
        for (var i=nowlength-1;i>=0;i--)
            {
            if (document.all.nowid.options[i].selected)
                {
                var newtext = document.all.nowid.options[i].text;
                var newvalue = document.all.nowid.options[i].value;
                var freelength = document.all.freeid.length;
                document.all.freeid.options[freelength] = new Option(newtext,newvalue);
                document.all.nowid.options[i] = null;
                }
            }
        }
    </script>
    <table border="0" cellspacing="0" cellpadding="0" align="left">
                        <tr>
                            <td>
                            <select name="freeid" multiple size="6" style="width:100px">
                                <option value="北京">北京</option>
                                <option value="上海">上海</option>
                                <option value="天津">天津</option>
                                <option value="重庆">重庆</option>
                                <option value="河北">河北</option>
                                <option value="山西">山西</option>
                                <option value="内蒙古">内蒙古</option>
                                <option value="辽宁">辽宁</option>
                                <option value="吉林">吉林</option>
                                <option value="黑龙江">黑龙江</option>
                                <option value="江苏">江苏</option>
                                <option value="浙江">浙江</option>
                                <option value="安徽">安徽</option>
                                <option value="福建">福建</option>
                                <option value="江西">江西</option>
                                <option value="山东">山东</option>
                                <option value="河南">河南</option>
                                <option value="湖北">湖北</option>
                                <option value="湖南">湖南</option>
                                <option value="广东">广东</option>
                                <option value="广西">广西</option>
                                <option value="海南">海南</option>
                                <option value="四川">四川</option>
                                <option value="贵州">贵州</option>
                                <option value="云南">云南</option>
                                <option value="西藏">西藏</option>
                                <option value="陕西">陕西</option>
                                <option value="甘肃">甘肃</option>
                                <option value="宁夏">宁夏</option>
                                <option value="青海">青海</option>
                                <option value="新疆">新疆</option>
                                <option value="香港">香港</option>
                                <option value="澳门">澳门</option>
                                <option value="台湾">台湾</option>
                            </select>
                          </td>
                            <td width="22%" align="center" valign="center">
                            <input type="button" class="it" value="添加>>" onclick="adduser()"><br/><br/>
                            <input type="button" class="it" value="<<删除" onclick="deluser()">
                            </td>
                            <td width="44%">
                            <select name="nowid" multiple size="6" style="width:100px">
                            </select>
                            </td>
                        </tr>
                      </table>
    然后把添加到右边的选项结果存到数据库,如"北京,山西,海南"
    现在我把它从数据库里提出来的时候,希望在左边多选框不显示上面三个地方,右边多选框显示不好意思,上面没有说清楚.