View Full Version : [urgent]how to change row color?

04-17-2003, 09:19 AM
have a problem when making msg box.
The msgs are generated by "for loop".
if the user did not read the msg, the color of the row will be different (highlighted) from others.
now, i try to make an effect that the row color will be changed from white to lightgrey when the mouse pointer is moving over the row.
but the problem is the row color of a new msg will also change to white color when the pointer out of the row.
The new msg is not shown with the highlighted color again.

here is my code. can u help me?

<script language="javascript">
function over_bg (obj) {
function out_bg (obj) {

<? for ($i = $no; $i > 0 ; $i--) { ?>
<tr onMouseOver="over_bg(this)" onMouseOut="out_bg(this)" <? If ($arr[$i][sstatus] == "new") { echo "style=\"background:#CECEFF\""; } ?>>
<td width="4%" height="25" align="center">
<input name="del[<?=$i?>]" type="checkbox" id="del[<?=$i?>]" value="<?=$arr[$i][msg_no]?>" <? If ($check == "all") { echo "checked"; }?>>
<td width="24%" align="left">
<a href="../member/member.php?user_no=<?=$arr[$i][receiver]?>">
<td width="44%" align="left">
<a href="sent_msg.php?msgid=<?=$i?>">
<td width="28%" align="left">
<? list($post_date, $time) = split( '[ ]', $arr[$i][post_date]);
echo $post_date;?>
<? } ?>

04-17-2003, 09:49 AM
extend your functions to take an additional parameter of colour hex value - actually you could easily combine them

function bg_swap( obj, hexref )

then in the php

$bg_ref = ($arr[$i][sstatus] == "new") ? 'CECEFF' : 'FFFFFF';
echo '<tr onMouseOver="bg_swap(this,\'E6E6E6\')" onMouseOut="bg_swap(this,\'' .$bg_ref. '\')" style="background:#' .$bg_ref. '">';

something like that anyway - flytyped so will probably need a bit more tinkering.

04-17-2003, 12:26 PM
u're very helpful~