Need help in Javascript Table Search

I want to search through this table according to the first row, serial number. But i cant figure out where is the problem in my Javascript code. Here is the link. https://jsfiddle.net/naeemrind/peqv5g7f/

Thanks in Advance :slight_smile:

I forked your fiddle to make some changes. Turns out you’re programmatically doing everything right (apart from one small thing) but you didn’t get the configuration right.

https://jsfiddle.net/AdityaParab/truhcpcn/1/

First, Click on javascript settings and change Load Type from onload to No wrap - in <head> This will make sure your function is defined BEFORE onload event is fired. You can see this setting in the fiddle above.

Secondly, what input.value.enumerable(); ? Specifically this .enumerable() part? You don’t need that.

Change

filter = input.value.enumerable();

to

filter = input.value;

AND change

if (td.innerHTML.enumerable().indexOf(filter) > -1) {

to

if (td.innerText.indexOf(filter) > -1) {

You don’t need innerHTML here for

  1. there are no tags nested inside your td:first elements
  2. Your input is going to be text, not html mark up.

Doing these changes, I can see rest of your code working correctly.

1 Like

Thank you so much. :slight_smile:
Actually I am new in Javascript.