javascript - Search if my HTMLCollection contains certain text -


i have search function properties allowing me search number of bedrooms, bathrooms, price (high , low) , trying tell me if customers search word, or words, in record. "river" or something.

i have been playing .contains() , .indexof() , can not either work. here few have tried;

for (var i=0;i<x.length;i++) { var item = x[i]; if (item.getelementsbytagname("bedrooms")[0].childnodes[0].nodevalue >= filterbed && item.getelementsbytagname("bathstotal")[0].childnodes[0].nodevalue >= filterbath && item.getelementsbytagname("listprice")[0].childnodes[0].nodevalue >= filterprl && item.getelementsbytagname("listprice")[0].childnodes[0].nodevalue <= filterprh && item.getelementsbytagname("publicremarks").text().tolowercase().contains(filterword) ) {  

and;

    && item.getelementsbytagname("publicremarks").indexof(filterword) 

i have tested key words coming through , have checked in records being searched.

any getting working appreciated.

try this, since using jquery:

$(item).find("publicremarks").text().tolowercase().indexof(filterword) > -1 

$() turn item dom jquery object. find publicremarks tags within it, extract text, make lowercase, , filterword. if filter word not found, indexof() return -1.


with javascript, done looping through collection. create function reduce levels of complexity in conditional... this:

jsfiddle

function collectioncontains(collection, searchtext) {     (var = 0; < collection.length; i++) {         if( collection[i].innertext.tolowercase().indexof(searchtext) > -1 ) {             return true;         }     }     return false; } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -