Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4258978
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:43:19+00:00 2026-05-21T05:43:19+00:00

I make some table use DataTable. I make this table can filtering data from

  • 0

I make some table use DataTable. I make this table can filtering data from each column.
This is some tfoot for filtering:

<tfoot>
       <tr>
           <th><input type="text" name="search_Date" value="Search Date" class="search_init" /></th>
           <th><input type="text" name="search_Model" value="Search Model" class="search_init" /></th>
           <th><input type="text" name="search_Qty" value="Search Qty" class="search_init" /></th>
           <th><input type="text" name="search_Name" value="Search Name" class="search_init" /></th>
       </tr>
</tfoot>

But how if I want to make the same thing if I make some additional table. So, we have two table in this page and also have a tfoot like the first table.

<tfoot>
       <tr>
           <th><input type="text" name="search_Date" value="Search Date" class="search_init" /></th>
           <th><input type="text" name="search_Line" value="Search Line" class="search_init" /></th>
           <th><input type="text" name="search_Model" value="Search Model" class="search_init" /></th>
           <th><input type="text" name="search_Lot_no" value="Search Lot_no" class="search_init" /></th>
           <th><input type="text" name="search_Range" value="Search Range" class="search_init" /></th>
        </tr>
</tfoot>

I don’t know how to modify the dataTable’s script. The script is like below:

 var asInitVals = new Array();
        $(document).ready(function() {
    var oTable;
    var aTable;

    oTable = $("#datadaily").dataTable({.......});   //1st table
    aTable = $("#unfinish").dataTable({.......});    //add. table

                $("tfoot input").keyup( function () {
                                /* Filter on the column (the index) of this element */
                                oTable.fnFilter( this.value, $("tfoot input").index(this) );
                                aTable.fnFilter( this.value, $("tfoot input").index(this) );
                                });

                /*
                 * Support functions to provide a little bit of 'user friendlyness' to the textboxes in 
                 * the footer
                 */
                $("tfoot input").each( function (i) {
                                asInitVals[i] = this.value;
                                });

                $("tfoot input").focus( function () {
                                if ( this.className == "search_init" )
                                {
                                        this.className = "";
                                        this.value = "";
                                }
                        });
                $("tfoot input").blur( function (i) {
                                    if ( this.value == "" )
                                    {
                                            this.className = "search_init";
                                            this.value = asInitVals[$("tfoot input").index(this)];
                                    }
                            });
});

Could I use one filtering script to control two tfoot? Ff so, how do I do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:43:19+00:00Added an answer on May 21, 2026 at 5:43 am

    You must specify what’s index of the tfoot you’ve click.
    Using code:

    var index = $(this).index("table tfoot");
    

    Then you should change your data struct:

    var TABLE_COUNT = 2;
    var DATA_ATABLE = 0;
    var DATA_OTABLE = 1;
    var tableData = [];
    tableData[DATA_ATABLE] = $("#datadaily").dataTable({.......
    tableData[DATA_OTABLE] = $("#unfinish").dataTable({.......
    

    Here is demo source:

    <table class="table-test" border="1">
        <thead>
            <tr>
                <th>Colum1</th>
                <th>Colum2</th>
                <th>Colum3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>B1</td>
                <td>B2</td>
                <td>B3</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>F1</th>
                <th>F2</th>
                <th>F3</th>
            </tr>
        </tfoot>
    </table>
    <table class="table-test"  border="1">
        <thead>
            <tr>
                <th>Colum1</th>
                <th>Colum2</th>
                <th>Colum3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>B1</td>
                <td>B2</td>
                <td>B3</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>F1</th>
                <th>F2</th>
                <th>F3</th>
            </tr>
        </tfoot>
    </table>
    <script>
        /*@const*/
        var TABLE_COUNT = 2;
        var DATA_ATABLE = 0;
        var DATA_OTABLE = 1;
        var tableData = [];
        tableData[DATA_ATABLE] = $("#datadaily").dataTable({.......
        tableData[DATA_OTABLE] = $("#unfinish").dataTable({.......
        $(".table-test tfoot").click(function(){
            var index = $(this).index(".table-test tfoot");
            //@Todo
            tableData[index] = ...................
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.