I have this function:

function changeTDNodes() {

var mycurrent_cell = document.getElementsByTagName("td")[19];

var ciq = mycurrent_cell.innerHTML;

ciq=parseInt(ciq)

if (ciq>3){mycurrent_cell.setAttribute("bgColor","red");}

}

And my problem is I can't get the

ciq>3

to work

if I set ciq=3

then it works no problem

the ciq value is 33

Thank you all for your assistance!

3 answers

0
points

You're not storing the result of parseInt anywhere, so you still have a string in ciq.

Answered about 9 years ago by Nathan Duran
  • Even if I have ciq = parseInt(ciq) the cell still stays uncolored. :( Andrew Madison about 9 years ago
0
points

Nathan Duran is correct. You aren't storing the result of parseInt. This code should work (I haven't tested it).

var mycurrent_cell = document.getElementsByTagName("td")[19];
var ciq = mycurrent_cell.innerHTML;
var ciqValue = parseInt(ciq)
if (ciqValue > 3)
{
  mycurrent_cell.setAttribute("bgColor","red");
}
Answered about 9 years ago by Wayne Johnston
  • I wish that was the answer, but even if I implement your solution above, the comparison still doesn't occur. It acts like it ignores the if statement all together. Andrew Madison about 9 years ago
0
points

Found the answer:

I was trying to style a <b> when I should have been styling a <td>

Thank you!

Answered about 9 years ago by Andrew Madison