![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
21/05/2010, 20:25
|
![Avatar de wiwi74](http://static.forosdelweb.com/customavatars/avatar220987_1.gif) | | | Fecha de Ingreso: marzo-2008
Mensajes: 515
Antigüedad: 16 años, 11 meses Puntos: 10 | |
Respuesta: Cambiar color background a DIV con checkBox Crea un archivo php y metele este codigo dentro de las etiquetas <body></body>
No toques nada, ya funciona, luego si, adaptalo.
Solo fijate en estas 2 lineas, que se genera un espacio " #ff0000" bueno quitalo que da error:
(se generan al darle a guardar, aqui en el foro)
document.getElementById(i).style.backgroundColor=" #ff0000"; //esta es una
document.getElementById(i).style.backgroundColor=" #ffffff"; //esta la otra (estan mas abajo)
El codigo:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<script type="text/javascript" language="javascript">
function darColor(paramID){
//alert(document.getElementsByTagName("tr").length);
for(i=0; i<(document.getElementsByTagName("tr").length); i++){
//alert(document.getElementById(i).id);
if(document.getElementById(i).id == paramID){
document.getElementById(i).style.backgroundColor=" #ff0000";
}else{
document.getElementById(i).style.backgroundColor=" #ffffff";
}
}
}
</script>
</head>
<body>
<form action="" method="post">
<table border="1" cellpadding="10">
<?
//CODIGO DINAMICO
for($i=0; $i<10; $i++){
echo'<tr id="'.$i.'"><td>
<input type="radio"
name="equipo"
value="equipo'.$i.'"
onclick="darColor('.$i.')" />
</td>
<td>
Contenido
</td>
</tr>';
}
?>
</table>
<BR /><input type="submit" value="MOSTRAR EL VALOR CHECADO" />
</form>
<?
echo "<br />".$_POST['equipo'];
?>
</body>
</html>
Última edición por wiwi74; 21/05/2010 a las 20:42 |