The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. July 22, 2019, 11:03:11 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: quick and dirty but cool  (Read 4405 times)
herbacious
Journeyman
***
Offline Offline

Posts: 51


View Profile
« on: March 16, 2011, 06:15:54 PM »

got a massive table of data

can't be arsed to create some kind of ajax blah blah blah autocomplete search thing

check this out

http://kobikobi.wordpress.com/2008/09/15/using-jquery-to-filter-table-rows/

basically just apply the class="filterable" to your table and then dump this in - uses jquery so assumes you are including that in the head etc

function filterBox(){
    
$return=<<<NOWDOC
<script type="text/javascript">
$(document).ready(function(){
    //add index column with all content.
    $(".filterable tr:has(td)").each(function(){
        var t = $(this).text().toLowerCase(); //all row text
        $("<td class='indexColumn'></td>")
        .hide().text(t).appendTo(this);
    });//each tr
    $("#FilterTextBox").keyup(function(){
        var s = $(this).val().toLowerCase().split(" ");
        //show all rows.
        $(".filterable tr:hidden").show();
        $.each(s, function(){
            $(".filterable tr:visible .indexColumn:not(:contains('"
                + this + "'))").parent().hide();
        });//each
    });//key up.
});//document.ready
</script>
<h1><b>Jquery Filter Box:</b><input id="FilterTextBox"/></h1>
NOWDOC;
    return 
$return;
}
Logged
herbacious
Journeyman
***
Offline Offline

Posts: 51


View Profile
« Reply #1 on: March 16, 2011, 06:17:39 PM »

sorry to clarify - cos im using it all over the place i put the JS into a PHP function so I can just go
<?php echo filterBox()?>
<table class="filterable>...etc

nice way of breathing life into legacy stuff
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: March 19, 2011, 12:09:22 AM »

I've not tried it but it looks strong. thanks Meng.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Sade
n00b
*
Offline Offline

Posts: 4


View Profile
« Reply #3 on: April 29, 2011, 12:20:46 AM »

I can't seems here any dirty and bad thing. Let me clear, what are you talking about, is there any specific thing..
I also want to ask from you about perkiset, What's the term abbreviated, Tell me in detail the meaning and purpose.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: April 30, 2011, 11:07:40 AM »

That  'Bot is strangely cool.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!