Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [urgent]how to change row color?

    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>
    <? } ?>
    .......

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks~

    u're very helpful~


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •