要下班了,时间太短,写了一个,基本功能实现了,你在自己测试下什么都不选等其他情况
<script language=javascript>
function d123()
{
var value=document.all.a123.options[document.all.a123.selectedIndex].value;
var text=document.all.a123.options[document.all.a123.selectedIndex].text;
document.all.a123.options[document.all.a123.selectedIndex]=null;
document.all.b123.options[document.all.b123.options.length]=new Option(value,text);
}
function e123()
{
var value=document.all.b123.options[document.all.b123.selectedIndex].value;
var text=document.all.b123.options[document.all.b123.selectedIndex].text;
document.all.b123.options[document.all.b123.selectedIndex]=null;
document.all.a123.options[document.all.a123.options.length]=new Option(value,text);
}
</script>
<select name=a123 size=5>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input name=c123 type=button value="-->" onclick=d123()>
<input name=f123 type=button value="<--" onclick=e123()>
<select name=b123 size=5>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>

解决方案 »

  1.   

    多谢。再请问
    1、select框的长度可以指定吗?(因为数据都是从数据库中读取的,如果不是固定的话,很不方便)
    2、想在请求在同一select框中,上移、下移的功能代码。
    1
    2
    3
    4
    move up  move down
      

  2.   

    你说的长度是指什么,select框的宽度?
    可以指定的
    <select name=a123 style="width:100">
    </select>
    上移下移的代码,五分钟后你再来看看
      

  3.   

    <script language=javascript>
    function d123()
    {
    if(document.all.a123.selectedIndex!=0)
    {
    var value=document.all.a123.options[document.all.a123.selectedIndex].value;
    var text=document.all.a123.options[document.all.a123.selectedIndex].text;
    var value1=document.all.a123.options[document.all.a123.selectedIndex-1].value;
    var text1=document.all.a123.options[document.all.a123.selectedIndex-1].text;
    var selectedIndex=document.all.a123.selectedIndex;
    var upselectedIndex=document.all.a123.selectedIndex-1 document.all.a123.options[selectedIndex]=new Option(value1,text1);
    document.all.a123.options[upselectedIndex]=new Option(value,text);
    }
    }
    function e123()
    {
    if(document.all.a123.selectedIndex!=document.all.a123.options.length)
    {
    var value=document.all.a123.options[document.all.a123.selectedIndex].value;
    var text=document.all.a123.options[document.all.a123.selectedIndex].text;
    var value1=document.all.a123.options[document.all.a123.selectedIndex+1].value;
    var text1=document.all.a123.options[document.all.a123.selectedIndex+1].text;
    var selectedIndex=document.all.a123.selectedIndex;
    var upselectedIndex=document.all.a123.selectedIndex+1 document.all.a123.options[selectedIndex]=new Option(value1,text1);
    document.all.a123.options[upselectedIndex]=new Option(value,text);
    }
    }</script>
    <select name=a123 size=5>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select>
    <input name=c123 type=button value="上移" onclick=d123()>
    <input name=f123 type=button value="下移" onclick=e123()>
      

  4.   

    可以了,想换个方式来做。请看:
    http://community.csdn.net/Expert/topic/4256/4256470.xml?temp=.8794824可否给我发些js的学习资料,[email protected]