473,320 Members | 2,041 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,320 software developers and data experts.

OnClick and change color

93
Hi
How do I make the cell change color to 'black' after I click on it. The cell will remain black color until I click another cell which will also change to black. I can do the mouseover and mouseout correctly only to make it change color to black once I click on it.

Could someone help?

Thansk
nma

[PHP]
<td width="<?php echo ($cellwidth); ?>" height="17" bgcolor="#00ff00" onMouseOver="this.style.background ='red'"
onMouseOut="this.style.background='#00ff00'" onClick="window.frames.eventsDisplay.location = 'MB2eventlistTimeline.php?movieID=<?php echo $movie->movieID;?>&events=<?php echo $timeline->eventCategory;?>#<?php echo $timeline->eventID?>'; parent.notesForm.eventID.value=<?php echo $timeline->eventID?>;parent.resetNotes();this.style.backgrou ndColor='black';" style="cursor: pointer;"></td>


[/PHP]
Mar 7 '08 #1
3 2697
acoder
16,027 Expert Mod 8TB
If you set the background onclick the onmouseout will change the background colour again. You will need to set a variable and check for this onmouseout if you want to avoid this.
Mar 7 '08 #2
nma
93
If you set the background onclick the onmouseout will change the background colour again. You will need to set a variable and check for this onmouseout if you want to avoid this.
Hi acoder

I don't really get you. What should I do?

Nma
Mar 7 '08 #3
acoder
16,027 Expert Mod 8TB
Hi acoder

I don't really get you. What should I do?

Nma
Assuming that that is the problem, declare a global variable, say clicked, to false. Then in the onclick add "clicked = false;". In onmouseout add "if (!clicked)" at the beginning so that if it's been clicked the mouse-out will not change the black background.
Mar 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Matt | last post by:
I created 3 hyperlinks, when the user click each link, it will change the color of the text of a link. For example, when user clicks Link1, text Link1 will become red color, but Link2 and Link3...
17
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to...
8
by: KS | last post by:
Just to show some code to show the consept. <img id="date" onclick="javascript:show_calendar();" src="/PlexSysWeb/images/show-calendar.gif" width=20 height=18 border=0> What i want the...
3
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
5
by: johnsuth | last post by:
I want to produce a trivial demonstration of dynamic modification. I thought that pressing a button might change its color. I studied O'Reillys books and successfully created the button with a...
2
by: Richard Morse | last post by:
Hi! I have an aspx that I've created which has an asp:Button in it. I would like to be able to change the OnClick handler at runtime (basically, I want this form to either edit or create a...
3
by: tshad | last post by:
I was trying to change my asp:button to asp:ImageButton, but got a message saying that ImageButton does not have an onClick function. How do I get the ImageButton call a function? Thanks, ...
10
by: apparker | last post by:
I'm creating a new GUI for a program and it is for a medical exam. There are so many different things to ask someone during a history it wastes too much space to make checkboxes for everything so I...
18
by: wizdom | last post by:
Help - change text on click - text has another onclick inside with php variables ---------- I think what I'm trying to do is simple. I have a 2 buttons on a page. 1 button allows a thread of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.