hi. wanna know how add table row highlighting everytime user hovers mouse. able alternate row color. total novice in web programming , have little knowledge of javascript. pls me this.
here codes:
display.php:
<table class="table_data"> <tr> <th><nobr>id</nobr></th> <th><nobr>first names</nobr></th> <th><nobr>gender</nobr></th> </tr> <?php $row_ctr = 1; while ($first_names_array = mysql_fetch_array($first_names)) { if (($row_ctr % 2) == 0) $alternate = "even"; else $alternate = "odd"; echo "<tr>"; echo "<td class='$alternate'><nobr>" . $first_names_array['id'] . "</nobr></td>"; echo "<td class='$alternate'><nobr>" . $first_names_array['first_name'] . "</nobr></td>"; echo "<td class='$alternate'><nobr>" . $first_names_array['gender'] . "</nobr></td>"; echo "</tr>"; $row_ctr += 1; } ?> </tr> </table>
and in css:
style.css
.odd { background-color: #525252; } .even { background-color: #b7acc6; } .highlight { background-color: #ff0; }
i don't have slightest idea how i've said row color alternation working. highlight having trouble with. total novice said earlier. pls help..
use class tr , following properties
echo "<tr class='highlightrow'>"; echo "<td class='$alternate'><nobr>" . $first_names_array['id'] . "</nobr></td>"; echo "<td class='$alternate'><nobr>" . $first_names_array['first_name'] . "</nobr></td>"; echo "<td class='$alternate'><nobr>" . $first_names_array['gender'] . "</nobr></td>"; echo "</tr>";
and css .highlightrow
.highlightrow:hover td { background-color: black; color: white; cursor: pointer; }
Comments
Post a Comment