<fieldset><legend><b>上下交换示例</b></legend>
<select id=s1 size=5>
<option name=s1>s1</option>
<option name=s2>s2</option>
<option name=s3>s3</option>
<option name=s4>s4</option>
<option name=s5>s5</option>
</select><script>
var temp;
function change(){
if (s1.selectedIndex>=0&&s1.selectedIndex<s1.length-1){  //判断是否在最后一个选项上 
temp=s1.options[s1.selectedIndex].text;
s1.options[s1.selectedIndex].text=s1.options[s1.selectedIndex+1].text;
s1.options[s1.selectedIndex+1].text=temp;
}
else{                                                    //如果在最后一项上就只与上面的交换
temp=s1.options[s1.selectedIndex].text;
s1.options[s1.selectedIndex].text=s1.options[s1.selectedIndex-1].text;
s1.options[s1.selectedIndex-1].text=temp;
}
}</script>
<input type=button value=交换 onclick=change()>
</fieldset><fieldset><legend><b>上下交换示例</b></legend>
<script>
function add(){
var opt=ss1.options[ss1.selectedIndex].text;
var ss=document.createElement("option");
ss.text=opt;
alert('您添加的项是'+opt);
ss2.add(ss);
}</script><select id=ss1 size=5>
<option name=s1>s1</option>
<option name=s2>s2</option>
<option name=s3>s3</option>
<option name=s4>s4</option>
<option name=s5>s5</option>
</select>
<input type=button value="添加" onclick=add()>
<select id=ss2 size=5></select>
</fieldset>

解决方案 »

  1.   

    完整版:可删除可添加:
    **********************************
    <fieldset><font color=blue><legend><b>上下交换示例</b></legend></font>
    <select id=s1 size=5>
    <option name=s1>s1</option>
    <option name=s2>s2</option>
    <option name=s3>s3</option>
    <option name=s4>s4</option>
    <option name=s5>s5</option>
    </select><script>
    var temp;
    function change(){
    if (s1.selectedIndex>=0&&s1.selectedIndex<s1.length-1){  //判断是否在最后一个选项上 
    temp=s1.options[s1.selectedIndex].text;
    s1.options[s1.selectedIndex].text=s1.options[s1.selectedIndex+1].text;
    s1.options[s1.selectedIndex+1].text=temp;
    }
    else{                                                    //如果在最后一项上就只与上面的交换
    temp=s1.options[s1.selectedIndex].text;
    s1.options[s1.selectedIndex].text=s1.options[s1.selectedIndex-1].text;
    s1.options[s1.selectedIndex-1].text=temp;
    }
    }</script>
    <input type=button value=交换 onclick=change()>
    </fieldset>
    <br><br><br><hr color=red><br><br><br>
    <fieldset><font color=blue><legend><b>添加示例</b></legend></font>
    <script>
    function add(){
    var opt=ss1.options[ss1.selectedIndex].text;
    var ss=document.createElement("option");
    ss.text=opt;
    alert('您添加的项是'+opt);
    ss2.add(ss);
    }function del(){
    ss2.remove(ss2.options[ss2.selectedIndex]);}
    </script><select id=ss1 size=5>
    <option name=s1>s1</option>
    <option name=s2>s2</option>
    <option name=s3>s3</option>
    <option name=s4>s4</option>
    <option name=s5>s5</option>
    </select>
    <input type=button value="添加" onclick=add()>
    <input type=button value="删除" onclick=del()>
    <select id=ss2 size=5></select>
    </fieldset>
      

  2.   

    HueVan :
    你的倒是可以实现,我只是想对表单进行操作,让某一行(可能是好几列啊)向上或向下移动.
    希望不吝赐教!