Hola
Prueba así
Código PHP:
<script language="JavaScript" type="text/javascript">
function perc() {
var a = document.getElementById("cantidad").value;
var b = (a/40)*100
if (b <=45)
{
document.getElementById("color").style.backgroundColor='red';
}
else if (b <=75)
{
document.getElementById("color").style.backgroundColor='yellow';
}
else if (b <= 100)
{
document.getElementById("color").style.backgroundColor='green';
}
}
</script>
Código:
<form name="form1">
<input type="text" name="cantidad" id="cantidad" value="" />
<input OnClick="perc();" type="button" value="Calculo" />
</form>
<table border="1">
<tr>
<td id="color">Estadistica</td>
</tr>
</table>
Suerte