首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

select 左右下上移动(支持多选)

2012-10-30 
select 左右上下移动(支持多选)script typetext/javascript//左右移动function LeftRightChangeOptio

select 左右上下移动(支持多选)
    <script type="text/javascript">
//左右移动
        function LeftRightChangeOptions(option,select){
var orderselect=document.getElementById(select);
for(var i=0;i<orderselect.options.length;i++)
{
if(option.value==orderselect.options[i].value)
break;
}
if(i==orderselect.options.length)
orderselect.options.add(new Option(option.text,option.value));

        }
        function LeftRightDirectionOnChange(select1,select2){
        var orderselect=document.getElementById(select1);

            for(var i=0;i<orderselect.options.length;i++)
            {
            if(orderselect.options[i].selected)
            {
            ChangeOptions(orderselect.options[i],select2);
orderselect.remove(i);
i--;
            }
            }
        
  
        }
//******************************************************************************
//上下移动
        function UpDownChangeOptions(int1,int2){
var orderselect=document.getElementById("lstbSubOrder");
var itemText=orderselect.options[int1].text;
var itemValue=orderselect.options[int1].value;
var itemSelect=orderselect.options[int1].selected;
orderselect.options[int1].text=orderselect.options[int2].text;
orderselect.options[int1].value=orderselect.options[int2].value;
orderselect.options[int1].selected=orderselect.options[int2].selected;
orderselect.options[int2].text=itemText;
orderselect.options[int2].value=itemValue;
orderselect.options[int2].selected=itemSelect;
        }
        function UpDownDirectionOnChange(direction){
        var orderselect=document.getElementById("lstbSubOrder");
        var cnt=orderselect.options.length;
          if(direction=="up")
          {
            for(var i=0;i<cnt;i++)
            {
            if(orderselect.options[i].selected)
            {
                if(i==0)
                        return;
            ChangeOptions(i-1,i);
            }
            }
          }
          else
          {
          for(var i=cnt-1;i>-1;i--)
          {
             
          if(orderselect.options[i].selected)
            {
                if(i==cnt-1)
                      return;
            ChangeOptions(i,i+1);
            }
          }
          }
        }
       
    </script>

热点排行