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

  • SEARCH
  • Home
  • 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 6964249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:54:03+00:00 2026-05-27T15:54:03+00:00

The following jQuery function filters my table columns by letter. There is an <a>

  • 0

The following jQuery function filters my table columns by letter. There is an <a> for each letter. I’m not sure how to add another function though to filter column 1 using a different dropdown on the html side.

JavaScript:

function fil(rexp)
{
    $('#tablestyle').dataTable().fnFilter(rexp, 0, true, false);
}

HTML:

<div style="float:left;" class="sortalpha">
    <a href="javascript:fil('');">ALL</a>
    | <a href="javascript:fil2('^a');">A</a>
    | <a href="javascript:fil('^b');">B</a>
    <!-- [...] -->
    | <a href="javascript:fil('^z');">Z</a>
</div>

What I have tried to do is copy the top part and change fil to fil2 then copy the HTML part and change those to fil2. Is that the correct way?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Just to give everyone a bit more info, I am using datatables {www.datatables.net} which is a jquery script that presents tables in a nice looking ui with various differnt functions to it like search, filter records per page etc.
I have implemented this mod that someone has listed here >> http://www.datatables.net/forums/discussion/6641/filtering-with-first-letter/p1

It works fine and when I select each letter it filters column 0 using whatever letter I have clicked on. What I am trying to do is have two different filters, one to filter column 0 which is the name of the person, and also another filter that does exaclty the same thing, but for column 1 which is business name, I just wasnt sure how to add the same piece of code twice?.

  • 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-27T15:54:04+00:00Added an answer on May 27, 2026 at 3:54 pm

    I don’t really know your context, but I would suggest you try using event handlers instead of JavaScript URLs.

    So instead of this:

    <a href="javascript:fil('');">ALL</a>
    

    You could do this:

    $('.sortalpha a').on('click', function() {
        fil('');
    });
    

    Of course, this would make all links filter on ''. To fix that, you could get the text from the <a> that was clicked and use that to call fil(), like so:

    function fil(rexp) {
        if (rexp.length > 0) {
            rexp = '^' + rexp;
        } 
        //$('#tablestyle').dataTable().fnFilter(rexp, 0, true, false);
        alert('Filter on: "' + rexp + '"');
    }
    
    $('.sortalpha a').on('click', function(event) {
    
        var letter = $(this).text().toLowerCase();
    
        if (letter === 'all') {
            fil('');
        } else {
            fil(letter);
        }
    });
    

    Here’s a working example: http://jsfiddle.net/uzGat/2/

    Edit: I updated the answer to account for capital letter and the ^ in the regular expressions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following JQuery function is not working entirely. IE 7 processes both alerts, but
I'm parsing a XML using jQuery with the following code: function appendNav(xml) { $(xml).find(Nav).each(function()
In the following jquery function, can someone explain to me why second is being
I have the following jquery function for filtering the contents of a listbox on
I have the following jquery function > <script type=text/javascript> > > $(document).ready(function() { >
I have the following jQuery function: $(function(){ if ($(.menu li).hasClass(active)) { $(.active).css(margin-top, 6px); }
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I would like to know if I can use the following JQuery function on
Using the following JQuery/AJAX function I'm calling a partial view when an option is
I have the following scenario jQuery('#content').fadeOut('slow',function(){ jQuery('#content').load(detail.php?product=+imgID+&category=+cat); jQuery('#content').fadeIn('fast'); }); My problem however is that

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.