1

在下面的屏幕截图中有 2 个框,用户将从左框到右选择他想要的任何项目。现在,用户在右侧框中选择了哪一列。我只需要这些项目。下面是屏幕截图和代码。在下面的屏幕截图中,我只需要从右框中获取一、二和三个值。那么,如何从右框中仅获取选定的项目?

获取正确的框值是 JavaScript 函数中的正确方法。请帮忙

function export()
    {                 
         <%if(request.getParameter("myServersID1") != null)
        {
              String[] ItemNames;

ItemNames = request.getParameterValues("myServersID1");

              for(int i = 0; i < ItemNames.length; i++)

              {
                     String selecteditems;

                     selecteditems= ItemNames[i];

                   System.out.println("selecteditems" +selecteditems);

        }}%>

        alert("selectcol"); 

    }   

添加按钮时

<input type="button" value="Export" class="btn-arrow-pri btn-small" style="margin-left: 300px;" onclick="export();"/>

_ _ _ ___

four   |    |

       |>   |one

five   |<   |two

       | >> |three

       |<<  |

_ ___

代码是:

<html>
[...]
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

  <script type="text/javascript">

    function moveRight(){
        $(document).ready(function(){
            $("#myserversID option:selected").appendTo("#myserversID1")
        });
    }

    function moveLeft(){
        $(document).ready(function(){
            $("#myserversID1 option:selected").appendTo("#myserversID")
        });
    }

  </script>
 </head>
 <body>

<select size="8" id="myserversID" multiple="multiple">
    <option value="one">one</option>
    <option value="two">two</option>
    <option value="three">three</option>
    <option value="four">four</option>
    <option value="five">five</option>
    <option value="six">six</option>
</select>

<input type="button" value="Move Right" onclick="moveRight();"/>
<input type="button" value="Move Left" onclick="moveLeft();"/>
<select size="8" id="myserversID1" multiple="multiple">  
</select>
 </body>
</html>
4

0 回答 0