0

So far, i have done creating report with paging. sample code index.php:

<div class='web'>    
    <h1>Data Order Notaris</h1>
        <div id="page_data"></div>
            <span class="flash"></span>
        </div>

and use script:

$(document).ready(function(){
                    change_page('0');
                });
                    function change_page(page_id){
                        $(".flash").show();
                        $(".flash").fadeIn(400).html('Loading <img src="ajax-loader.gif" />');
                        var dataString = 'page_id='+ page_id;
                            $.ajax({
                                type: "POST",
                                url: "paging.php",
                                data: dataString,
                                cache: false,
                                    success: function(result){
                                        $(".flash").hide();
                                        $("#page_data").html(result);
                                    }
                            });
                    }

my file for show paging is paging.php my problem when using live search. i am trying add input type in index.php

add input script:

<input type='text' name='search' placeholder='search' />

i think it doesn't need form and submit button. how to post value from input name='search' to paging.php for filter data report?

is it need more function or using function change_page? i am still confuse with logic. thanks for help

4

1 回答 1

2

您应该以这种方式输入:

 <input type='text' Id="search_box" name='search' placeholder='search' />

然后使用js你可以获取这个字段的值

所以你的js代码将是:

$(document).ready(function(){
                    change_page('0');
                });
                    function change_page(page_id){
                        //To get the field value
                        var search_val = $("#search_box").val();
                        $(".flash").show();
                        $(".flash").fadeIn(400).html('Loading <img src="ajax-loader.gif" />');
                        var dataString = 'page_id='+ page_id+'&search='+search_val;
                            $.ajax({
                                type: "POST",
                                url: "paging.php",
                                data: dataString,
                                cache: false,
                                    success: function(result){
                                        $(".flash").hide();
                                        $("#page_data").html(result);
                                    }
                            });
                    }

然后在您的 page.php 中进行适当的查询 :)

于 2016-10-04T03:58:44.430 回答