0
Guys I’m having 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 personal my problem is the following, when executing this part: if(categorias.indexOf(noticia.categoria)>=0)
I want to see if the category of the news exists in the categories arrray and so far everything works well, presents only the news with the category that are selected by checkbox, the problem comes in the following line, when doing this: if(categorias.indexOf(procura)>=0)
What I was supposed to do was to receive a string stored in the search variable and check if there is a category with the name of the string but this part doesn’t work and I don’t know why... The search variable is filled here.
function procurar() {
$("#Procurar").click(function(){
procura = ($("#TEXTO").val());
escreveNoticias();
});
}
I even made one alert
to see if the string reached the escreveNoticias
and comes my problem is right in the indexOf
...
Someone can help me?!?!
Thank you very much, I’ve already solved my problem!
– Hugo
If you can, consider adding an answer telling us how you did it to solve your problem, so you can help others who have the same problem.
– Miguel Angelo