Re: [PHP-ES] Alternar color en filas de una tabla

From: PHP ( php .en. techead.com)
Date: Fri Mar 26 2004 - 19:06:20 CET


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?



This archive was generated by hypermail 2.1.7 : Fri May 14 2004 - 16:04:42 CEST