我的JSP项目中要实现以下功能: 
页面中有两个数据列表A和B(数据列表实现方式不限,但不要下拉列表),其中A为从数据库表FIELDS中读出的所有数据,B为空数据列表,在页面上选中A列表中的一行或多行数据,点击"加入"按钮,将选中的数据加入B列表中并删除A列表中相应数据,相反,选中B列表中的一行或多行数据,点击“删除”按钮,将B中数据还原到A中。 
请哪位高手大大给出解决方案,很急,谢谢了!!!

解决方案 »

  1.   

    <html>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function moveSome(sFrom,sTo){
        var sf = document.getElementById(sFrom).options;
        var tf = document.getElementById(sTo).options;
        var p  = tf.length;
        //var tmpArr = new Array();
        for(var i=sf.length-1;i>=0;i--){
            if(sf[i].selected){
                var value = sf[i].value;
                var text = sf[i].text;
                tf.add(new Option(text,value),p);
                sf.remove(i);
            }
        }
    }看看这个可以不?是不是你想要得!function moveAll(sFrom,sTo){
        var sf = document.getElementById(sFrom).options;
        var tf = document.getElementById(sTo).options;
        for(var i=0;i<sf.length;){
            tf.add(new Option(sf[0].text, sf[0].value));
            sf[0] = null;
        }
    }//-->
    </SCRIPT><body>
    <table border=0>
      <tr>
        <td>
            <select name="selectFrom" size="10" style="width: 150px;" multiple ondblclick="moveSome('selectFrom','selectTo')">
              <option value="1">test 1</option>
              <option value="2">test 2</option>
              <option value="3">test 3</option>
              <option value="4">test 4</option>
              <option value="5">test 5</option>
              <option value="6">test 6</option>
              <option value="7">test 7</option>
            </select>
        </td>
        <td align="center">
            <input type="button" value=" > "  onclick="moveSome('selectFrom','selectTo')"><p>
            <input type="button" value=" < "  onclick="moveSome('selectTo','selectFrom')"><p>
            <input type="button" value=" >> " onclick="moveAll('selectFrom','selectTo')"><p>
            <input type="button" value=" << " onclick="moveAll('selectTo','selectFrom')"><p>
        </td>
        <td>
            <select name="selectTo" size="10" style="width: 150px;" multiple ondblclick="moveSome('selectTo','selectFrom')">        </select>
        </td>
      </tr>
    </table>
    </body>
    </html>
      

  2.   


    看看这个可以不?是不是你想要得!
    <html>
    <SCRIPT LANGUAGE="JavaScript">function moveSome(sFrom,sTo){
        var sf = document.getElementById(sFrom).options;
        var tf = document.getElementById(sTo).options;
        var p  = tf.length;
        for(var i=sf.length-1;i>=0;i--){
            if(sf[i].selected){
                var value = sf[i].value;
                var text = sf[i].text;
                tf.add(new Option(text,value),p);
                sf.remove(i);
            }
        }
    }
    function moveAll(sFrom,sTo){
        var sf = document.getElementById(sFrom).options;
        var tf = document.getElementById(sTo).options;
        for(var i=0;i<sf.length;){
            tf.add(new Option(sf[0].text, sf[0].value));
            sf[0] = null;
        }
    }</SCRIPT><body>
    <table border=0>
      <tr>
        <td>
            <select name="selectFrom" size="10" style="width: 150px;" multiple ondblclick="moveSome('selectFrom','selectTo')">
              <option value="1">test 1</option>
              <option value="2">test 2</option>
              <option value="3">test 3</option>
              <option value="4">test 4</option>
              <option value="5">test 5</option>
              <option value="6">test 6</option>
              <option value="7">test 7</option>
            </select>
        </td>
        <td align="center">
            <input type="button" value=" > "  onclick="moveSome('selectFrom','selectTo')"><p>
            <input type="button" value=" < "  onclick="moveSome('selectTo','selectFrom')"><p>
            <input type="button" value=" >> " onclick="moveAll('selectFrom','selectTo')"><p>
            <input type="button" value=" << " onclick="moveAll('selectTo','selectFrom')"><p>
        </td>
        <td>
            <select name="selectTo" size="10" style="width: 150px;" multiple ondblclick="moveSome('selectTo','selectFrom')">        </select>
        </td>
      </tr>
    </table>
    </body>
    </html>