SEOClerks

Improve my Javascript code for a search table function.

Improve my Javascript code for a search table function.

I have a search bar that will filter results in a table.
I would like the script to ignore any words in the search bar that do not match a keywords or items.


[Search Bar]

Item1Keyword1
Item2Keyword2
Item3Keyword3 Keyword4

Working
  • Search: "Item1" will display Item1 row
  • Search: "Keyword3" will display Item3 row
  • Search: "Keyword4 Keyword3" will display Item3 row

Not Working (please help me fix this)
  • Search: "Keyword1 Keyword3" will display Item1 and Item3 row
  • Search: "Keyword1 hello world" will display Item1 row

HTML
<input type="text" id="search" placeholder="Type to search">

<table id="table">

<tr>

<td>Item1</td>

<td>Keyword1</td>

</tr>

<tr>

<td>Item2</td>

<td>Keyword2</td>

</tr>

<tr>

<td>Item3</td>

<td>Keyword3 Keyword4</td>

</tr>

</table>

<br>

<b>Working</b>

<p>Search: "Item1" will display Item1 row (working)</p>

<p>Search: "Keyword3" will display Item3 row (working)</p>

<p>Search: "Keyword4 Keyword3" will display Item3 row (working)</p>

<br>

<b>Not Working (please help me fix this)</b>

<p>Search: "Keyword1 Keyword3" will display Item1 and Item3 row (not working)</p>

<p>Search: "Keyword1 hello world" will display Item1 row (not working)</p>

Javascript Jquery

var $rows = $('#table tr');

$('#search').keyup(function() {



var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*
,

reg = RegExp(val, 'i'),

text;



$rows.show().filter(function() {

text = $(this).text().replace(/\s+/g, ' ');

return !reg.test(text);

}).hide();

});


Requirements

Fix the search bar so I can search...

  • Search: "Keyword1 Keyword3" will display Item1 and Item3 row
  • Search: "Keyword1 hello world or any other words not found in table" will display Item1 row.
  • You can edit the code, or re-write all of the code.
  • You can use Javascript or Jquery.


Skills Required

javascript jquery

Bids

hello

have a good day!

i have done several projects like this bur new in freelancer. i am confident that i will do your work very well. i hope you would like my smart work and be fully satisfied .

thank you for reading my request

thanks and regards.

shabbir ahmed

Bid On Listing Created 6 years ago in Programming

Other jobs by brandonberner

Order Now
Process Time: 0.12543392181396

Possible Duplicate queries found!
MatchCountSQLScript
SELECT * FROM wanttobuy A, categories_wanttobuy B, seoclerks.members C WHERE A.wantid='73503' AND A.category=B.CATID AND A.USERID=C.USERID1SELECT A.*, B.name, B.seo, C.username, C.userlevel, C.footer_code, C.rating, C.ratingcount, C.googleplus_profile, C.total_recommendations, C.USERID, C.profilepicture, C.average_response_time, C.lastlogin, C.addtime FROM wanttobuy A, categories_wanttobuy B, seoclerks.members C WHERE A.wantid='73503' AND A.category=B.CATID AND A.USERID=C.USERID

/opt/clerks-staging/docroot/viewwant.php 163 () ()

SELECT * FROM seoclerks.members_recommendations WHERE USERID=383448 AND status=1 ORDER BY MRID DESC limit 11SELECT recommendation_text, FROMID, time_added FROM seoclerks.members_recommendations WHERE USERID=383448 AND status=1 ORDER BY MRID DESC limit 1

/opt/clerks-staging/docroot/include/functions/main.php 21955 getLastRecommendation() ()

SELECT * FROM seoclerks.members WHERE USERID='272'1SELECT username FROM seoclerks.members WHERE USERID='272'

/opt/clerks-staging/docroot/include/functions/main.php 1577 insert_get_username_from_userid() ()

SELECT * FROM ratings_buyer WHERE USERID=3834481SELECT sum(good) as thumbup, sum(bad) as thumbdown FROM ratings_buyer WHERE USERID=383448

/opt/clerks-staging/docroot/include/functions/main.php 19523 GetRatingsAsBuyerTotal() ()

SELECT * FROM wanttobuy A, categories_wanttobuy B WHERE A.wantid != 73503 AND A.category=B.CATID AND A.active=1 AND (A.tags like '%javascript jquery%' ) LIMIT 41SELECT A.wantid, A.title, A.p1, A.maxprice, B.name, B.seo FROM wanttobuy A, categories_wanttobuy B WHERE A.wantid != 73503 AND A.category=B.CATID AND A.active=1 AND (A.tags like '%javascript jquery%' ) LIMIT 4

/opt/clerks-staging/docroot/viewwant.php 551 () ()

SELECT * FROM wanttobuy A, categories_wanttobuy B WHERE A.wantid != 73503 AND A.category=B.CATID AND A.active=1 AND A.USERID=383448 LIMIT 41SELECT A.wantid, A.title, A.p1, A.maxprice, B.name, B.seo FROM wanttobuy A, categories_wanttobuy B WHERE A.wantid != 73503 AND A.category=B.CATID AND A.active=1 AND A.USERID=383448 LIMIT 4

/opt/clerks-staging/docroot/viewwant.php 568 () ()

SELECT * FROM wantcomments a, seoclerks.members b WHERE a.PID='73503' AND a.USERID=b.USERID and b.status='1' AND a.status=1 order by a.CID asc1SELECT a.comment, a.USERID, a.CID, a.time_added, a.istranslated, a.parentid, b.username, b.profilepicture FROM wantcomments a, seoclerks.members b WHERE a.PID='73503' AND a.USERID=b.USERID and b.status='1' AND a.status=1 order by a.CID asc

/opt/clerks-staging/docroot/viewwant.php 835 () ()

UPDATE wanttobuy SET viewcount = viewcount + 1 WHERE wantid='73503'1UPDATE wanttobuy SET viewcount = viewcount + 1 WHERE wantid='73503'

/opt/clerks-staging/docroot/include/functions/main.php 1729 update_wantviewcount() ()

SELECT * FROM wantbids as w, seoclerks.members AS m WHERE w.active=1 AND m.USERID=w.USERID AND m.status=1 AND w.USERID>0 AND w.wantid='73503' ORDER BY w.bidid ASC 1SELECT w.bidid, w.PID, w.comment, w.title, w.pricepublic, w.USERID, w.adjustedprice, w.ip, m.profilepicture FROM wantbids as w, seoclerks.members AS m WHERE w.active=1 AND m.USERID=w.USERID AND m.status=1 AND w.USERID>0 AND w.wantid='73503' ORDER BY w.bidid ASC

/opt/clerks-staging/docroot/viewwant.php 1192 () ()

SELECT * FROM seoclerks.members as m WHERE m.USERID=9639701SELECT m.username, m.skills, m.userlevel, m.ip, m.total_recommendations FROM seoclerks.members as m WHERE m.USERID=963970

/opt/clerks-staging/docroot/viewwant.php 1258 () ()

SELECT * FROM categories_wanttobuy1SELECT * FROM categories_wanttobuy

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() parseRedundantQueriesCache()

SELECT * FROM posts WHERE USERID=3834481SELECT sum(positive_ratings) as thumbup, sum(negative_ratings) as thumbdown FROM posts WHERE USERID=383448

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() GetBuyerRatingsTotal()

SELECT * FROM categories1SELECT * FROM categories

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() parseRedundantQueriesCache()

select * from categories_software order by name asc1select * from categories_software order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_GetSoftwareCategories()

select * from categories_wanttobuy order by name asc1select * from categories_wanttobuy order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_wantcategories()

select * from categories_wanttotrade order by name asc1select * from categories_wanttotrade order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_tradecategories()

SELECT * FROM seoclerks.members WHERE USERID='963970'1SELECT profilepicture FROM seoclerks.members WHERE USERID='963970'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='383448'1SELECT profile_data FROM seoclerks.members WHERE USERID='383448'

/opt/clerks-staging/docroot/include/functions/main.php 1927 getUserBackground() include()

Invalid SQL

count(*)sql1error_msg

Expensive SQL

Tuning the following SQL could reduce the server load substantially
LoadCountSQLMaxMin

Suspicious SQL

The following SQL have high average execution times
Avg TimeCountSQLMaxMin
0.1053761SELECT A.wantid, A.title, A.p1, A.maxprice, B.name, B.seo FROM wanttobuy A, categories_wanttobuy B WHERE A.wantid != 22799 AND A.category=B.CATID AND A.active=1 AND (A.tags like '%Twitterfollowa Twitters Tweets%' ) LIMIT 40.1053760.105376
0.0932841SELECT * FROM members WHERE show_freelancer = 1 AND status = 1 AND total_recommendations > 0 AND (skills LIKE '%digitalartist%') ORDER BY total_recommendations desc LIMIT 0,400.0932840.093284
0.0661011SELECT count(USERID) AS total FROM members WHERE show_freelancer = 1 AND status = 1 AND total_recommendations > 0 AND (skills LIKE '%digitalartist%') 0.0661010.066101
0.0591541SELECT A.wantid, A.title, A.p1, A.maxprice, B.name, B.seo FROM wanttobuy A, categories_wanttobuy B WHERE A.wantid != 73503 AND A.category=B.CATID AND A.active=1 AND (A.tags like '%javascript jquery%' ) LIMIT 40.0591540.059154