1
I’m trying to compare the value of a column of a table
, so that depending on what is selected, show or hide the field, I arrived in this code:
td = tr[i].getElementsByTagName("td")[3];
console.log(td);
debugger;
if (td == $('#Produtos').prop("checked",true)) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
But it is not filtering, how to correct?
in the console.log(td)
is showing up like this <td>True</td>
depending on each line, am I taking wrong the value?
Try to do this,
var tbBoolean = $(td).text() == "True" ? true : false;
this code checks if the text inside td is equal"True"
, ai Voce can check thetdBoolean == $('#Produtos').prop("checked")
. Detail: doing it here$('#Produtos').prop("checked",true)
You are checking the checkbox– Icaro Martins
@Icaromartins when I do this, it returns me the following error: tdBoolean is not defined
– Mariana
You have to harvest this line first, right after the console.log.
var tbBoolean = $(td).text() == "True" ? true : false;
– Icaro Martins
I did it, it returned error on this line
if (tbBoolean == $('#Produtos').prop("checked")) {
– Mariana
I made a mistake tdBoolean and then tbBoolean, and just turn everyone to
tdBoolean
– Icaro Martins
You gave it right, if you want to release the answer, I’ll mark it for you, thank you. @Icaromartins
– Mariana