zoukankan      html  css  js  c++  java
  • 实现两个select list box间item的移动和过滤

    <head>
        <title>
        </title>    
        <!--Standard jQuery -->
        <script type="text/javascript" src="https://code.jquery.com/jquery-git2.js" charset="utf-8"></script>
        <script type="text/javascript">
            $(document).ready(function()
            {
                $('#boxClear').click(function(){
                    $('#firstFilterSearch').val('');
                });
    
                $('#firstFilterSearch').keyup(function()
                {
                    var searchArea = $('#firstList');
                    searchFirstList($(this).val(), searchArea);
                });
    
                $('#firstList').dblclick(function() {
                    assignList();
                });
    
                $('#secondList').dblclick(function() {
                    unassignList();
                });
    
                $('#to2').click(function()
                {
                    assignList();
                });
    
                $('#to1').click(function()
                {
                    unassignList();
                });
            });
                
            // Function for Filtering
            function searchFirstList(inputVal, searchArea)
            {
                var allCells = $(searchArea).find('option');
                if(allCells.length > 0)
                {
                    var found = false;
                    allCells.each(function(index, option)
                    {
                        var regExp = new RegExp(inputVal, 'i');
                        if(regExp.test($(option).text()))
                        {
                            $(option).show();
                        }
                        else
                        {
                            $(option).hide();
                        }
                    });
                }
            }
    
            // function: UnAssignment
            function assignList()
            {
                $('#firstList :selected').each(function(i, selected){
                    // append to second list box
                    $('#secondList').append('<option value="'+selected.value+'">'+ selected.text+'</option>');
                    // remove from first list box
                    $("#firstList option[value='"+ selected.value +"']").remove();
                });
            }
            // function: UnAssignment
            function unassignList()
            {
                $('#secondList :selected').each(function(i, selected){
                    // append to first list box
                    $('#firstList').append('<option value="'+selected.value+'">'+ selected.text+'</option>');
                    // remove from second list box
                    $("#secondList option[value='"+ selected.value +"']").remove();
                });
            }
        </script>
    </head>
    <body>
    <table border="0" cellpadding="0" cellspacing="0" width="100%">    
        <tr>        
            <td width="100%">
                <form id="frm_format" method="" action="">
                <table cellpadding="0" id="tbl_format"cellspacing="0" border="0" width="100%" class="standard_table_v4">    
                    <thead>
                    </thead>
                    <tbody>
                        <tr>
                            <td>
                            <td align="center">
                                Filter: <input id="firstFilterSearch" type="text">
                                        <input type="button" id="boxClear" name="boxClear" value="Cancel"><br>
                                <select id="firstList" multiple="multiple" style="height:420px; 250px;" >    
                                    <option value="1">PHP</option>
                                    <option value="2">.Net</option>
                                    <option value="3">Copy</option>
                                    <option value="4">Paste</option>
                                    <option value="5">Pea</option>
                                    <option value="6">Pamp</option>
                                    <option value="7">ladaku</option>
                                    <option value="8">Zebra</option>
                                </select>
                            </td>
                            <td align="center">
                                <input id="to2" type="button" name="to2"  title='assign' value=">" /><br/><br/>
                                <input id="to1" type="button" name="to1" title='unassign' value="<">
                            </td>
                            <td>
                                <select id="secondList" multiple="multiple" style="height:420px; 250px;" >
                                </select>
                            </td>
                        </tr>
                    </tbody>
                </table>
                </form>
                
            </td>
        </tr>
    </table>
    </body>
    </html>
  • 相关阅读:
    mvc:resources配置说明
    MySQL 表与索引损坏修复
    ORACLE 日志损坏 使用"_ALLOW_RESETLOGS_CORRUPTION"进行崩溃恢复
    Oracle 回滚段坏快并恢复
    Oracle 坏快处理:Undo 与 datafile
    Oracle备份恢复-控制文件损坏的各种场景恢复专题
    Oracle备份恢复-redo文件损坏的各种场景恢复专题
    Oracle 数据库坏块处理技术
    PostgreSQL 坏快分类与修复策略
    Linux RAID卡优化
  • 原文地址:https://www.cnblogs.com/dereklovecc/p/3998698.html
Copyright © 2011-2022 走看看