var x = 65;
do {
if (x >= 75) {
// The line while be printer even
// if the condition is false
document.write("<tr><td>");
document.write(x);
document.write("</td>");
document.write("<td>");
document.write("FAILED");
document.write("</td>");
} else {
document.write("<tr><td>");
document.write(x);
document.write("</td>");
document.write("<td>");
document.write("PASSED");
document.write("</td>");
}
So in here I need it to be Color red when failed and green when passed but I know how too change font color but I don't know it when it's in table and need to be if-else statement? Please help!
Set the color via a style attribute:
style="color:red" or style="color:green" on the <tr>
like this:
var x = 65;
do {
if (x >= 75) {
// The line while be printer even
// if the condition is false
document.write("<tr style='color=red'><td>");
document.write(x);
document.write("</td>");
document.write("<td>");
document.write("FAILED");
document.write("</td>");
} else {
document.write("<tr style='color=green'><td>");
document.write(x);
document.write("</td>");
document.write("<td>");
document.write("PASSED");
document.write("</td>");
}
Of course you could / should do this not via inline-styles but put the definitions in css classes and then put the class on the rows.
#red {
color:red;
}
#green {
color:green;
}
document.write('<p id="red">FAILED</p>')
document.write('<p id="green">PASSED</p>')