Re: Alternar color en filas de una tabla
| From: | PHP | Date: | Fri, 26 Mar 2004 18:06:20 +0000 |
| Subject: | Re: Alternar color en filas de una tabla | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-47175@lists.php.net to get a copy of this message | ||
Idea 1:
JAVASCRIPT:
<script language=JavaScript>
function setrowcolor(therow, thecolor) {
if (thecolor == '' || typeof(therow.style) == 'undefined') {
return false;
}
if (typeof(document.getElementsByTagName) != 'undefined') {
var thecells = therow.getElementsByTagName('td');
} else if (typeof(therow.cells) != 'undefined') {
var thecells = therow.cells;
} else {
return false;
}
var rowcellscnt = thecells.length;
for (var i = 0; i < rowcellscnt; i++) {
thecells[i].style.backgroundColor = thecolor;
}
return true;
}
</script>
En HTML / PHP BODY
$color=1;
while($something=mysql_fetch_object($sql)){
if($color==1){
echo "<tr bgcolor='#F5F5EF'
onMouseOver=\"setrowcolor(this,'#D5E2EE')\"
onMouseOut=\"setrowcolor(this,'#F5F5EF')\">";
$color=0;
}else{
echo "<tr onMouseOver=\"setrowcolor(this,'#D5E2EE')\"
onMouseOut=\"setrowcolor(this,'#FFFFFF')\">";
$color=1;
} ?>
Idea 2:
.... dime si la necesitas
<? PHP ?>
On Fri, 2004-03-26 at 13:00, Jose Mª Hidalgo wrote:
> ¿Cómo se hace eso de alternar el color de los <td> de la tabla cuando los
> <td> estan dentro del while que muestra los resultados de la BD?