我就想实现增加或者删除某个用户,用这种形式

解决方案 »

  1.   

    就是左边一个框 可能是textarea 右边也有一个,中间有>  和 < 
     比如左边的框里有几行 每行是一个用户, 选中他 然后点一下>  这个用户就被移动到到右边框里
    现在我要在一个JSP页面里实现 该怎么实现呢?
      

  2.   

    你说的实现方式都是才用javaScript,你去找这方面的资料看看吧,
      

  3.   

    建两个select框id分别为“DropDownList1”,“DropDownList2”,然后利用下面脚本试试        function moveRight() {
                var source = document.getElementById("DropDownList1");
                var purpose = document.getElementById("DropDownList2");
                if (source.selectedIndex > -1) {
                    var size = source.length;
                    for (var i = 0;i < size; i++) {
                        if (source.options[i].selected) {
                            purpose.options.add(new Option(source[i].text,source[i].value));
                            source.options.remove(i);
                            i = i -1;
                            size = size - 1;
                        }
                    }
                } else {
                    alert("请选择要移动的城市!");
                    return false;
                }
            }
            function moveLeft() {
                var source = document.getElementById("DropDownList2");
                var purpose = document.getElementById("DropDownList1");
                if (source.selectedIndex > -1) {
                    var size = source.length;
                    for (var i = 0;i < size; i++) {
                        if (source.options[i].selected) {
                            purpose.options.add(new Option(source[i].text,source[i].value));
                            source.options.remove(i);
                            i = i -1;
                            size = size - 1;
                        }
                    }
                } else {
                    alert("请选择要移动的城市!");
                    return false;
                }
            }
            function moveUp(){
                var source = document.getElementById("DropDownList2");
                if (source.selectedIndex > -1) {
                    var size = source.length;
                    var tempText = "";
                    var tempValue = "";
                    for (var i = 0;i < size; i++) {
                        if (source.options[i].selected) {
                            //alert(source.options[i].index);
                            if (source.options[i].index != 0) {
                                tempText = source.options[i].text;
                                tempValue = source.options[i].value;
                                source.options[i].text = source.options[i-1].text;
                                source.options[i].value = source.options[i-1].value;
                                source.options[i-1].text = tempText;
                                source.options[i-1].value = tempValue;
                                source.options[i].selected = false;
                                source.options[i-1].selected = true;
                            } else {
                                alert("已经到达最上端!");
                                return false;
                            }
                        }
                    }
                } else {
                    alert("请选择要移动的城市!");
                    return false;
                }
            }
            function moveDown(){
                var source = document.getElementById("DropDownList2");
                if (source.selectedIndex > -1) {
                    var size = source.length;
                    var tempText = "";
                    var tempValue = "";
                    for (var i = size-1;i > -1; i--) {
                        if (source.options[i].selected) {
                            //alert(source.options[i].index);
                            if (source.options[i].index != size-1) {
                                tempText = source.options[i].text;
                                tempValue = source.options[i].value;
                                source.options[i].text = source.options[i+1].text;
                                source.options[i].value = source.options[i+1].value;
                                source.options[i+1].text = tempText;
                                source.options[i+1].value = tempValue;
                                source.options[i].selected = false;
                                source.options[i+1].selected = true;
                            } else {
                                alert("已经到达最下端!");
                                return false;
                            }
                        }
                    }
                } else {
                    alert("请选择要移动的城市!");
                    return false;
                }
            }