Skip to content Skip to sidebar Skip to footer

Filter Table With Multiple Radio Inputs

All I want is filter the table with radio inputs. This is my jsfiddle I am using this inputs and table:

Solution 1:

Try this, more simple:

$('input[type="radio"]').change(function () {
    var name = $('input[name="name"]:checked').prop('id') || '';
    var position = $('input[name="position"]:checked').prop('id') || '';
    $('tr').hide();
    $('tr:contains(' + name + ')').show();
    $('tr').not(':contains(' + position + ')').hide();
});

Demo here

The only change in the HTML you need is to have the ID of the position radio buttons to be the same as the table. The that information can be used in the tr show/hide. Like:

<inputtype="radio"id="Developer" name="position" />Developer
<inputtype="radio"id="Manager" name="position" />Manager

Post a Comment for "Filter Table With Multiple Radio Inputs"