Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
changing table row colour on mouse over and out
Old 04-14-2008, 10:07 AM changing table row colour on mouse over and out
Experienced Talker

Latest Blog Post:
Long time no … erm post?
Posts: 45
Name: Matthew Bagley
Trades: 0
hey guys, having some probs here for some weird reason my Javascript code isn't working how it should.

The idea is you can move the mouse over the table row and it will highlight the current row, now that works fine but I also want it so that if you click the row then it will change it to a darker colour which also works, now here is the trublesome part, when you moe the mouse away from this row then it should stay the same colour!

this is what I came up with
Code:
        if ($bgcolor == '#FFFFFF')$bgcolor = '#F3F3F3';
        else $bgcolor = '#FFFFFF';
?>
                <tr bgcolor="<?=$bgcolor;?>" onmouseover="if (this.bgColor = '<?=$bgcolor;?>'){this.bgColor = '#DDDDDD'} else {this.bgColor = '#CCCCCC';}" onmouseout="if (this.bgColor = '#DDDDDD'){this.bgColor = '<?=$bgcolor;?>'} else {this.bgColor = '#CCCCCC';}" onclick="this.bgColor = '#CCCCCC';">
but when you move the mouse out of the row that has been clicked on it resets the colour to the value of $bgcolor anyone have any ideas?

btw tried to put the onmouseover and that lot into a function but then it didn't work at all which i found totally weird
__________________
Matthew Bagley
Paramiliar Design Studios

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Paramiliar is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-14-2008, 11:59 AM Re: changing table row colour on mouse over and out
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Do we get to see a URL so we can see the code working (or not as the case may be)?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-14-2008, 12:05 PM Re: changing table row colour on mouse over and out
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
In your if you are using the assignment operator (=), you need to use the comparison operator (==).

Code:
if (this.bgColor == '<?=$bgcolor;?>')
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 04-14-2008, 01:00 PM Re: changing table row colour on mouse over and out
Experienced Talker

Latest Blog Post:
Long time no … erm post?
Posts: 45
Name: Matthew Bagley
Trades: 0
I figured it out finally, I always use capital letters for HEX values (so #FFFFFF instead of #ffffff) for some reason javascript was reading this.bgColor as LOWER CASE letters and when I did the equalto it was upper case (if (#ffffff == #FFFFFF) ) which of course wouldn't work, change all the background colours to lower case and the **** thing works :@

btw here is the code if anyone wants it
Code:
<tr bgcolor="<?=$bgcolor;?>" onmouseover="if (this.bgColor == '<?=$bgcolor;?>'){this.bgColor = '#dddddd'} else {this.bgColor = '#cccccc';}" onmouseout="if (this.bgColor == '#cccccc'){this.bgColor = '#cccccc'} else {this.bgColor = '<?=$bgcolor;?>';}" onclick="if (this.bgColor == '#cccccc'){this.bgColor = '<?=$bgcolor;?>';} else {this.bgColor = '#cccccc';}">
__________________
Matthew Bagley
Paramiliar Design Studios

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Paramiliar; 04-14-2008 at 01:31 PM.. Reason: SOLUTION
Paramiliar is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to changing table row colour on mouse over and out
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.96309 seconds with 12 queries