ondrag event can't be binded to "option"!

解决方案 »

  1.   

    用js或者jsp实现也可以
    同样送分
      

  2.   

    晕菜,楼主想象力丰富,阿信都说不可以了,jsp——更离谱了
      

  3.   

    <select id=test size=7 onmousedown="this.dragenable=true;this.setCapture();curOption=this.options[getIndex(this)]" onmousemove="if(this.dragenable==true)swapOption(this)" onmouseup="this.dragenable=false;this.releaseCapture();this.releaseCapture();"><option>选项一</option><option>选项二</option><option>选项三</option><option>选项四</option><option>选项五</option><option>选项六</option><option>选项七</option></select><button onclick="up(test)">向上</button>
    <button onclick="down(test)">向下</button>
    <script>
    var curOption=new Option();function up(obj)
    {
    if(obj.selectedIndex!=-1) {
    var obj1=obj.options(obj.selectedIndex);
    if (obj.selectedIndex>0)
    obj1.swapNode(obj1.previousSibling);
    }
    }
    function down(obj)
    {
    if(obj.selectedIndex!=-1) {
    var obj1=obj.options(obj.selectedIndex);
    if (obj.selectedIndex<obj.options.length-1)
    obj1.swapNode(obj1.nextSibling);
    }
    }function swapOption(obj) {
    if(curOption!=null && curOption!=obj.options[getIndex(obj)] && getIndex(obj)>-1 && getIndex(obj)<obj.size)curOption.swapNode(obj.options[getIndex(obj)]);
    }function getIndex(obj) {
    var theIndex=Math.floor((event.offsetY+2)/(obj.offsetHeight/obj.size));
    if(theIndex<0)theIndex=0;
    else if(theIndex>obj.options.length)theIndex=obj.options.length;
    return theIndex;
    }</script>
      

  4.   

    我是说阿信没有提到,不是说他说不可以。谢谢 西风瘦马
    不过我不知道button1和2是作甚么用的
    而且在拖动时有时会看到错误的顺序
    如果我把7拖到1,在放开鼠标以前我有把7向下拖
    则顺序就乱了
    请赐教