473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

change color in row

sr
please help
i have problem:
I know how to change color row in table when my mouse is over on this row
and change color to another color when my mouse is out from this row.
but i dont know how to change color when i click on this row and change to
third color and ,this color stay when my mouse is out.please help
Oct 12 '06 #1
6 3919
sr <sr@opgk.koszalin.plwrote:
please help
i have problem:
I know how to change color row in table when my mouse is over on this row
and change color to another color when my mouse is out from this row.
but i dont know how to change color when i click on this row and change to
third color and ,this color stay when my mouse is out.please help
You could call a function on the mouseOut-Event which checks the
background color of the row. And then you can decide what to do:

function colorCheck(object) {

// get background color of object
var bgColor = object.style.backgroundColor;

// if background color is NOT yellow change it to white
if ( bgColor != 'rgb(255, 255, 0)' ) {
object.style.backgroundColor = '#ffffff';
}
}

HTH
../otto
--
http://www.wean.at +++ http://www.lang-kritz.at
:wq
Oct 12 '06 #2
Otto Lang wrote on 12 okt 2006 in comp.lang.javascript:
var bgColor = object.style.backgroundColor;
if ( bgColor != 'rgb(255, 255, 0)' ) {
<div style='background-color:yellow;'
onclick='alert(this.style.backgroundColor)'>
xxxxxxxxxxxx</div>

The above in IE6 and FF1.5 will alert: "yellow"

<div style='background-color:#f00;'
onclick='alert(this.style.backgroundColor)'>
xxxxxxxxxxxx</div>

will in IE 6alert #f00
in FF1.5 rgb(255, 0, 0)
<div style='background-color:rgb(255, 255, 0);'
onclick='alert(this.style.backgroundColor)'>
xxxxxxxxxxxx</div>

The above in IE6 will alert: "rgb(255,255,0)"
and in FF1.5 will alert: "rgb(255, 255, 0)"
[mind the spaces]

==========

So your test will not be cross browser, and probably not in browser
dependable.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 12 '06 #3
Evertjan. <ex**************@interxnl.netwrote:
So your test will not be cross browser, and probably not in browser
dependable.
Sorry, such mistakes are not good :( I've forgotten IE and the named
colors. So he will have to make a lot more of tests to get the function
working: And maybe a lot more of tests for Safari and other browsers

../otto
Oct 12 '06 #4
Otto Lang wrote on 12 okt 2006 in comp.lang.javascript:
Evertjan. <ex**************@interxnl.netwrote:
>So your test will not be cross browser, and probably not in browser
dependable.

Sorry, such mistakes are not good :( I've forgotten IE and the named
colors. So he will have to make a lot more of tests to get the function
working: And maybe a lot more of tests for Safari and other browsers
What can be done however is this, IE6 and FF1.5 tested:

<style>
..red {background-color:#ff0000;}
..blueish {background-color:#01e;}
</style>

<div class='red'
onclick='alert((this.className=="red")?"A red color":"Another color")'>
xxxxxxxxxxxx</div>

<div class='blueish'
onclick='alert((this.className=="red")?"A red color":"Another color")'>
xxxxxxxxxxxx</div>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 12 '06 #5
Evertjan. <ex**************@interxnl.netwrote:
What can be done however is this, IE6 and FF1.5 tested:

<style>
.red {background-color:#ff0000;}
.blueish {background-color:#01e;}
</style>

<div class='red'
onclick='alert((this.className=="red")?"A red color":"Another color")'>
xxxxxxxxxxxx</div>

<div class='blueish'
onclick='alert((this.className=="red")?"A red color":"Another color")'>
xxxxxxxxxxxx</div>
Yes, class names seem to be a good idea. This should also work with
Safari an NetKit-based browsers. I'll test it in the evening when I'm
back at my Mac.

../otto
Oct 12 '06 #6
Evertjan. <ex**************@interxnl.netwrote:
What can be done however is this, IE6 and FF1.5 tested:

<style>
.red {background-color:#ff0000;}
.blueish {background-color:#01e;}
</style>

<div class='red'
onclick='alert((this.className=="red")?"A red color":"Another color")'>
xxxxxxxxxxxx</div>

<div class='blueish'
onclick='alert((this.className=="red")?"A red color":"Another color")'>
xxxxxxxxxxxx</div>
Okay, I tested this option on the Mac with IE 5.2, FF 1.5 and Safari 2
and it works with all of them properly. So I think the OP can use
className to decide how to change the background color.

../otto
Oct 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: kchengso | last post by:
One of my printers in my printer.devicename call returns in lower case. Is it possible for me to change it to upper case? I am also wondering how, in the first place, this particular printer...
2
by: Sami | last post by:
I keep getting the famous 'Too Many Connection' Error, and don't know how to change my variables, so they persist even if i have to restart mysql service. Platform: Windows 2003 Server My...
4
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
8
by: Patrick Kowalzick | last post by:
Dear NG, I would like to change the allocator of e.g. all std::strings, without changing my code. Is there a portable solution to achieve this? The only nice solution I can think of, would be...
3
by: roger beniot | last post by:
I would like to figure out how to detect an IP address change for an XP/Win2K3 machine that is leasing an IP via DHCP (and do it in C#)... Is there any event that indicates an IP address...
1
by: Anthony Boudouvas | last post by:
Hi to all, i have a treeview that i put some nodes in it with their repsective images. If i try to change the image and set it to some other ImageList index, nothing happens. The code i use...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
5
by: who be dat? | last post by:
Hello all. I'm writing an application that is writing trace information that can be viewed in trace.axd. I would like to rename this and use a different name specific to my application. I know...
4
by: active | last post by:
It appears to me that if I change the Control's client size the controls size does not change to agree with the new size. Does it work like the VB6 ScaleWidth and ScaleHeight? That is after I...
3
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.