Avatar of Coast Line
Coast Line
Flag for Canada asked on

Issues with the Code which i am trying to do in jquery for filtering and hiding showing

Having a code where I need to do the following,

Having a dropdown, I will select the item from the dropdown and it will create show the hidden TD and filter the whole table based on that, once I select its default option, it will again hide the TD column of that specific search dropdown and show all records of the table

Its is like on dropdown selection - filter and showing of TD column is required

on its default selection of dropdown - clear filter and hide the the TD Column

I hope i made the things clear here, if any doubts, please ask
$().ready(function () {
$("#idea").change(function(e) {
    $('table.data').find('tbody tr').hide();
    var ndata = $("#idea").val();
    var len=ndata.length;
        $('table.data tbody tr').each(function(){
            if(coldata.text().toUpperCase() == ndata.toUpperCase()) {
            else if(ndata == 'select One'){

Open in new window


my HTML Code

<table width="100%" border="0" cellspacing="2" cellpadding="1" class="data center">
            <th width="3%">&nbsp;</th>
            <th width="4%">&nbsp;</th>
            <th width="3%">&nbsp;</th>
            <th width="8%">a#</th>
            <th width="15%">b</th>
            <th width="14%">cBy</th>
            <th width="18%">d.</th>
            <th width="22%">e?</th>
            <th width="13%">idea</th>
        <tr> goes here</tr>

Open in new window

The question is about two things, Code is working partially and

1. On Drop Down selection filter records based upon its selection and show the hidden TD column

2. Back when default option of Dropdown is selected, clear all filtered records and hide the the TD Column of that associated dropdown

Avatar of undefined
Last Comment
Coast Line

8/22/2022 - Mon

Sorry but I'm not quite clear on your description.  In particular I didn't understand this part, can you elaborate & define "TD"?

"it will create show the hidden TD"

Looking at the code, I think I see where you are showing the column on filter condition: If you want the column hidden when no selection is made (or perhaps I misunderstnd), dont you want to HIDE it under the "select one" condition?
Coast Line

TD means table column

1. I want to hide the TD and clear the filter also it when the condition is (select one).. anytime

2. I want to show the TD if the condition is changed to something else and based upon that condition, it filters the records too to show in the full table structure, and again doing a select one.. resets the filter

please let me know if still not clear
Rainer Jeschor

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Coast Line

Hi, You made my Day,

Cheers rainer, Merry xmas
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck