473,587 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing the Color

I have some elements that I want to change color when I mouse over them
and them back on mouse off.

I'd like the color to remain with "#c7d0e0" when the user clicks on
them.

<td style="cursor:h and;"
onMouseOver="th is.style.backgr ound='#c7d0e0'; "
onMouseOut="thi s.style.backgro und='#ffffff';"
onClick="chg_th e_color();">
Description
</td>

Any help is appreciated.

Jul 23 '05 #1
13 1851
Ivo
"mike" wrote

I'd like the color to remain with "#c7d0e0" when the user clicks on
them.

<td style="cursor:h and;"
onMouseOver="th is.style.backgr ound='#c7d0e0'; "
onMouseOut="thi s.style.backgro und='#ffffff';"
onClick="chg_th e_color();">
Description
</td>


Try:
onclick="this.o nmouseout=null; "

hth
--
Ivo
Jul 23 '05 #2
mike wrote on 28 feb 2005 in comp.lang.javas cript:
I have some elements that I want to change color when I mouse over them
and them back on mouse off.

I'd like the color to remain with "#c7d0e0" when the user clicks on
them.

<td style="cursor:h and;"
onMouseOver="th is.style.backgr ound='#c7d0e0'; "
onMouseOut="thi s.style.backgro und='#ffffff';"
onClick="chg_th e_color();">
Description
</td>

Any help is appreciated.


<td
style="cursor:h and;background-color:#ffffff;"
onMouseOver="
this.save='#fff fff';
this.style.back groundColor='#c 7d0e0'"
onMouseOut="thi s.style.backgro undColor=this.s ave"
onClick="this.s ave='#c7d0e0'">
Description
</td>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #3
How do I turn that back on?

Jul 23 '05 #4
mike wrote on 28 feb 2005 in comp.lang.javas cript:
How do I turn that back on?


This is NOT email, but usenet.

Quote where you are talking about.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #5
Evertjan,

Good stuff. Works great.Only thing is I have many of these like:

<tr id="row1">
style="cursor:h and;background-color:#ffffff;"
onMouseOver="th is.save='#fffff f';
this.style.back groundColor='#c 7d0e0'"
onMouseOut="thi s.style.backgro undColor=this.s ave"
onClick="this.s ave='#c7d0e0'">
Description
</td>
</tr>
<tr id="row2">
<td
style="cursor:h and;background-color:#ffffff;"
onMouseOver="th is.save='#fffff f';
this.style.back groundColor='#c 7d0e0'"
onMouseOut="thi s.style.backgro undColor=this.s ave"
onClick="this.s ave='#c7d0e0'">
Description
</td>
</tr>

and when I click on "row1" then of course it keeps the background
color.
when I click on "row2" it keeps the background color as well.
I'd like to turn off "row1".

Thanks for your help, Mike

Jul 23 '05 #6
mike wrote:

[snip]
<td style="cursor:h and;"
The value, hand, is invalid for the cursor property. You're looking
for 'pointer':

cursor: pointer;

Rather than setting this property via an inline style attribute, use a
sensible selector and set the value in a global style sheet.
onMouseOver="th is.style.backgr ound='#c7d0e0'; "
onMouseOut="thi s.style.backgro und='#ffffff';"
onClick="chg_th e_color();">
Description
</td>
var stickyColour = (function(stick y, normal) {
var active = null;

function setBackground(e , c) {
if(e.style) {e.style.backgr oundColor = c;}
}

return {
change : function(o) {
/* If the element, o, isn't the currently active
* element, set its background colour. This check
* isn't strictly necessary, but it does prevent
* unnecessary style changes.
*/
if(o != active) {setBackground( o, sticky);}
},
persist : function(o) {
/* If there is already an active element and that
* element isn't o, restore it's background colour.
*/
if(active && (o != active)) {
setBackground(a ctive, normal);
}
/* Save a reference to the new active element. */
active = o;
},
restore : function(o, e) {
/* If the element, o, isn't active but it is the
* target of the event, e, restore its background
* colour. This prevents bubbling events from
* triggering this code.
*/
if((o != active) && (o == (e.target || e.srcElement))) {
setBackground(o , normal);
}
}
};
})('#c7d0e0', '#ffffff');

<td onmouseover="st ickyColour.chan ge(this);"
onmouseout="sti ckyColour.resto re(this, event);"
onclick="sticky Colour.persist( this);"Description</td>


Feel free to shorten the object (stickyColour) and method identifiers.

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #7
mike wrote on 01 mrt 2005 in comp.lang.javas cript:
Evertjan,

Good stuff. Works great.Only thing is I have many of these like:

<tr id="row1">
style="cursor:h and;background-color:#ffffff;"
onMouseOver="th is.save='#fffff f';
this.style.back groundColor='#c 7d0e0'"
onMouseOut="thi s.style.backgro undColor=this.s ave"
onClick="this.s ave='#c7d0e0'">
Description
</td>
</tr>
<tr id="row2">
<td
style="cursor:h and;background-color:#ffffff;"
onMouseOver="th is.save='#fffff f';
this.style.back groundColor='#c 7d0e0'"
onMouseOut="thi s.style.backgro undColor=this.s ave"
onClick="this.s ave='#c7d0e0'">
Description
</td>
</tr>

and when I click on "row1" then of course it keeps the background
color.
when I click on "row2" it keeps the background color as well.
I'd like to turn off "row1".
[please always quote relevant parts. this is not email, but usenet.
others want to follow the conversation and news servers are not always
obliging]
I'd like to turn off "row1".


I thought we were talking about individual cells

Try this:

<table><tr><t d
style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this)'
onMouseOut='myO ut(this)'
onClick='myClic k(this)'>
Description
</td><td
style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this)'
onMouseOut='myO ut(this)'
onClick='myClic k(this)'>
Description
</td></tr><tr><td
style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this)'
onMouseOut='myO ut(this)'
onClick='myClic k(this)'>
Description
</td></tr></table>

<script type='text/javascript'>
var myCellSave=fals e;
function myClick(myThis) {
if (myCellSave==my This){
myCellSave=fals e
myThis.style.ba ckgroundColor=' #ff0000'
return
}
if (myCellSave){
myCellSave.styl e.backgroundCol or='#ffffff'
}
myCellSave=myTh is
myThis.style.ba ckgroundColor=' #c7d0e0'
}
function myOver(myThis){
if (myCellSave!=my This){
myThis.style.ba ckgroundColor=' #ff0000'
}
}
function myOut(myThis){
if (myCellSave!=my This){
myThis.style.ba ckgroundColor=' #ffffff'
}
}
</script>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #8
That works great. I am now trying to add some other columns to that
functionality. I'd like the first column to stay highlited when I go to
the next column I tried this, but it does not isolate the column. Still
working on it. Any suggestions?

<td id="td_1">
<table>
<tr>
<td style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this,'td_1 ')'
onMouseOut='myO ut(this,'td_1') '
onClick='myClic k(this,'td_1')' >
Col 1, Row 1
</td>
</tr>
<tr>
<td style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this,'td_1 ')'
onMouseOut='myO ut(this,'td_1') '
onClick='myClic k(this,'td_1')' >
Col 1, Row 2
</td>
</tr>
<tr>
<td style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this,'td_1 ')'
onMouseOut='myO ut(this,'td_1') '
onClick='myClic k(this,'td_1')' >
Col 1, Row 3
</td>
</tr>
</table>
</td>
<td id="td_2">
<table>
<tr>
<td style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this,'td_2 ')'
onMouseOut='myO ut(this,'td_2') '
onClick='myClic k(this,'td_2')' >
Col 2, Row 1
</td>
</tr>
<tr>
<td style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this,'td_2 ')'
onMouseOut='myO ut(this,'td_2') '
onClick='myClic k(this,'td_2')' >
Col 2, Row 2
</td>
</tr>
<tr>
<td style='cursor:h and;background-color:#ffffff;'
onMouseOver='my Over(this,'td_2 ')'
onMouseOut='myO ut(this,'td_2') '
onClick='myClic k(this,'td_2')' >
Col 2, Row 3
</td>
</tr>
</table>
</td>

<script language="JavaS cript">
var myCellSave=fals e;
var myColSave=false ;
function myClick(myThis, myCol)
{
alert( "cellsave: " + myCellSave + " " +myThis+" colsave:"+
myColSave+" "+myCol);
if (myCellSave==my This && myColSave==myCo l)
{
myCellSave=fals e;
myColSave=false ;
myThis.style.ba ckgroundColor=' #c7d0e0';
return;
}
if (myCellSave && myColSave)
{
myCellSave.styl e.backgroundCol or='#ffffff';
}
myCellSave=myTh is;
myColSave=myCol ;
myThis.style.ba ckgroundColor=' #c7d0e0';
}
function myOver(myThis,m yCol)
{
if (myCellSave!=my This && myColSave!=myCo l)
{
myThis.style.ba ckgroundColor=' #c7d0e0';
}
}
function myOut(myThis,my Col)
{
if (myCellSave!=my This && myColSave!=myCo l)
{
myThis.style.ba ckgroundColor=' #ffffff';
}
}
</script>

Jul 23 '05 #9
mike wrote on 01 mrt 2005 in comp.lang.javas cript:
That works great. I am now trying to add some other columns to that
functionality. I'd like the first column to stay highlited when I go to
the next column I tried this, but it does not isolate the column. Still
working on it. Any suggestions?


I leave you to it. The principles being layed out, it must be possible to
programme your own requirements.

You could give the first column cells a seperate className?

Do not make those long sequences but start programming in modules you can
test independently.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #10

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

Similar topics

15
2376
by: oom | last post by:
I am a bit of a newbie when it comes to python, when working with lists today I noticed some very odd behaviour, any suggestions welcome: Python 2.2.3 (#1, Nov 6 2003, 14:12:38) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> firstlist= >>> secondlist=firstlist >>> print (firstlist,secondlist)
3
3436
by: Geoff Soper | last post by:
I'm trying to dynamically change the cursor of a couple of maps over an image. Basically the image is in an online photo system where there is a rotate mode. In this mode clicking on the left or right half of the image rotates it 90 degrees to the left or right. I want to change the cursor to indicate this but only while in the rotate mode....
2
1716
by: Urs Vogel | last post by:
Hi When using XmlDocument, I can create nodes and attributes as I like. What I didn't achieve is changing the Value of a node (created with createElement), it claims that it's the wrong node type. When changing the InnerText, I loose all child nodes. When cloning the node and reassigning the child nodes of the original node to the cloned...
6
1936
by: Eric | last post by:
I have an array, result. I populate the array and add it to an ArrayList. I then change result and add the new version to the ArrayList. However, when I go to review the ArrayList, all of the result 's are the same. How can I stop this from happening? I tried copying the array but that didn't work.
10
1689
by: Altman | last post by:
I have only done a little programming in C++ so I am still learning but I am having a problem with a variable that is changing on me. I have tried this 2 ways with the same result. I have a private long variable that keeps changing for no reason. I have a trace file running to tell me what is going on. Here is kind of what is happening ...
1
1809
by: Pablo | last post by:
I do not know like changing the color of bottom of: a menu, of the bar of the title of form, messagebox?
32
3658
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's RecordSource like this? Am I asking for trouble doing this with a memo field? Thanks in advance. Private Sub cmdNextNote_Click() Dim lngNid As Long...
12
4522
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in another forum from Peter Huang that said that an id="bg" as follows... <body MS_POSITIONING="GridLayout" runat="server" id="bg"> then we could do...
2
9027
by: Jim Frazer | last post by:
Hi, I'm working on an application in C# that will allow the user to create simple CAD drawings on a CEPC system. I would like to be able to change the cursor shape depending on the drawing mode selected by the user. I started out by setting up P/Invokes for LoadCursor and SetCursor. Calling LoadCursor followed by SetCursor does allow me...
4
1832
by: andychambers2002 | last post by:
I'm working on a "TempFile" class that stores the data in memory until it gets larger than a specified threshold (as per PEP 42). Whilst trying to implement it, I've come across some strange behaviour. Can anyone explain this? The test case at the bottom starts a TempFile at size 50 and prints its type. It then increases the size to the...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.