...

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



Terence
04-17-2003, 10: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) {
obj.style.background="#E6E6E6";
}
function out_bg (obj) {
obj.style.background="";
}
</script>
....

<? 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>
<td width="24%" align="left">
<a href="../member/member.php?user_no=<?=$arr[$i][receiver]?>">
<?=$arr[$i][nickname]?>
</a>ˇ@</td>
<td width="44%" align="left">
<a href="sent_msg.php?msgid=<?=$i?>">
<?=$arr[$i][title]?>
</a>ˇ@</td>
<td width="28%" align="left">
<? list($post_date, $time) = split( '[ ]', $arr[$i][post_date]);
echo $post_date;?>
ˇ@</td>
</tr>
<? } ?>
.......

Ökii
04-17-2003, 10: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 )
{
obj.style.background="#"+hexref;
}

then in the php

for(........)
$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.

Terence
04-17-2003, 01:26 PM
u're very helpful~
:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum