Ver Mensaje Individual
  #2 (permalink)  
Antiguo 31/07/2008, 14:37
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 2 meses
Puntos: 126
Respuesta: Problema para mostrar el color del resultado en una tabla

Hola

Prueba así

Código PHP:
 <script language="JavaScript" type="text/javascript">
function 
perc() {
var 
a  document.getElementById("cantidad").value;
var 
= (a/40)*100
    
if (<=45)
    { 
    
document.getElementById("color").style.backgroundColor='red';
    }
    else if  (
<=75)
    { 
    
document.getElementById("color").style.backgroundColor='yellow';
    }
    else if (
<= 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
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />