Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member [Li] Brad's Avatar
    Join Date
    Oct 2003
    Location
    Saskatoon, Canada
    Posts
    578
    Member #
    3689
    I use PHP to take data from an SQL database and arrange it in a table, with code like so:
    PHP Code:
    echo "   <td><b>" $db['Pos'] . "</b></td>";
    echo 
    "   <td><b>" $db['GP'] . "</b></td>";
    echo 
    "   <td><b>" $db['G'] . "</b></td>";
    echo 
    "   <td><b>" $db['A'] . "</b></td>"
    I want to make it so that when someone mouseovers one of the rows, that row's background color changes to a light grey so:
    Code:
    <script type="text/javascript"> 
    function newColor(color) 
    { 
    document.getElementById('x').style.background=color 
    } 
    </script>
    For the JavaScript and:
    PHP Code:
       echo " <tr id=\"x\" onmouseover=\"newColor('#eeeeee')\" onmouseout=\"newColor('#FFFFFF')\">"
    for the mouseover of the particular table row. The problem is that this code is in a loop, so all the table's rows end up having the same id: 'x'. Even if I could change the id on each row (the amount of rows will never be static), I would then need xnumber of functions to work on different id's, will I not? If anyone knows a good solution, I look forward to reading it.

    [Li] Brad
    "Art strives for form, and hopes for beauty." - George Bellows

  2.  

  3. #2
    Senior Member [Li] Brad's Avatar
    Join Date
    Oct 2003
    Location
    Saskatoon, Canada
    Posts
    578
    Member #
    3689
    Alright, ignore the post before this, I thought of something else that might work: can I use CSS to change a <tr> background color on mouseover, basicly like a link color change but applied to a table row?

    [Li] Brad
    "Art strives for form, and hopes for beauty." - George Bellows

  4. #3
    Senior Member justlivyalife's Avatar
    Join Date
    Jul 2003
    Location
    Birmingham, UK
    Posts
    2,871
    Member #
    2374
    Yeah you can...

    Using a script from Dynamic Drive :-
    http://www.dynamicdrive.com/dynamici...lighttable.htm
    There is a website on it, using CSS, Though you have to register to view it:
    http://www.gotfusion.com/tutsCH/css_rollovers.cfm
    justlivyalife - The future depends on what we do in the present. (Mahatma Gandhi)
    WDF Resources: WDF Rules
    Non-WDF: JavascriptSource | Dynamic Drive | phpBB | HTML-Kit | Winamp | Download Firefox | Morguefile


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:22 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com