Personally I have a problem with the code.
function escreveNoticias() {
var table_body = $("#lista-noticias tbody");
table_body.empty();
for (var i = 0; i<noticias.length; i++) {
noticia = noticias[i];
if (categorias.indexOf(noticia.categoria)>=0) {
if (categorias.indexOf(procura)>=0) {
var linha = "<tr class=\"realce\"><td>" + "<span>Titulo:</span>" + noticia.titulo + " " + " " + " " + " " + "<br><br>" + "<span>Categoria:</span>" + noticia.categoria + " " + " " + " " + " " + "<br><br>" + "<span>Data:</span>" + noticia.data + "<br><br>" + "<span>Subtitulo</span>" + noticia.subtitulo + "<br><br>" + "<span>Artigo:</span>" + noticia.artigo + "<br><br>" + "</td><tr>";
table_body.append(linha);
}
}
}
}
Well, my problem is the following, when I run this part: if(categorias.indexOf(noticia.categoria)>=0)
I want to see if the category of the news exists in arrray categories and so far everything works fine, only the news with the category that is selected through the problem comes in the following line, when doing this: if(categorias.indexOf(procura)>=0)
what I was supposed to do was to get a string stored in the search variable and check if there is any category with the string name but this part does not work and I do not know because ... The search variable is populated here.
function procurar() {
$("#Procurar").click(function(){
procura = ($("#TEXTO").val());
escreveNoticias();
});
}
I even made a alert
to see if the string arrived at escreveNoticias
and then my problem is actually at indexOf
...
Can someone help me?!?!