Jquery关键字搜索

时间:2014-04-15 19:34:09

标签: javascript jquery ajax

我正在使用jquery从显示的列表中搜索记录。通过从显示记录的表中输入单个单词或完整单词来搜索记录。现在问题是在记录表中我有一列id。当用户输入id号时,相应地搜索记录。我想允许用户从指定的列i-e搜索记录:标题,作者等不是id / pages。

这是jquery代码:

$(function () {
    $( '#table' ).searchable({
        striped: true,
        oddRow: { 'background-color': '#f5f5f5' },
        evenRow: { 'background-color': '#fff' },
        searchType: 'fuzzy'
    });

    $( '#searchable-container' ).searchable({
        searchField: '#container-search',
        selector: '.row',
        childSelector: '.col-xs-4',
        show: function( elem ) {
            elem.slideDown(100);
        },
        hide: function( elem ) {
            elem.slideUp( 100 );
        }
        })
    });

这是我的HTML代码:

<div class="container">


        <div class="row" style="padding-top:20px;">
            <div class="col-lg-4 col-lg-offset-4" style="padding-left: 130px; padding-top: 30px;">
                <input type="search" id="search" value="" class="form-control" placeholder="Search by Book Title/Author/Publisher">
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <table class="table" id="table">
                    <thead style="background: none repeat scroll 0 0 #6D6C6C">

                        <tr>
                            <th>#</th>
                            <th id="book" class="b">Book Title</th>
                            <th id="book" class="b">Author</th>
                            <th id="book" class="b">Publisher</th>
                            <th>Pages</th>
                            <th></th>
                        </tr>

                    </thead>
                    <tbody>
                        <?php

                        $x=0;

                        foreach ($result as $row) {?>

                        <tr>
                            <td ><?php echo $x = $x+1; ?></td>
                            <td id="book" class="b"><?php echo $row->TITLE; ?></td>
                            <td id="book" class="b"><?php echo $row->AUTHOR; ?></td>
                            <td id="book" class="b"><?php echo $row->PUBLISHER; ?></td>
                            <td><?php echo $row->PAGES; ?></td>
                            <td><a href="<?php echo $row->PATH; ?>" style="text-decoration:none;" target="_blank"><input id="button" class="btn btn-success" type="submit" value="View" name="submit"></a></td>
                        </tr>

                        <?php } ?>

                    </tbody>

                </table>
                <hr>
            </div>
                <div id="page" style="float: left; width: 100%; text-align: center">

                </div>

        </div>

    </div>

0 个答案:

没有答案