Hi
Can anyone help me..
How can I make onClick color remains the same =red?
Currently if it is mouseover it change to red, onmouseover it change to original background color. I need it to remain red once it is click so that I know where is the last location I click on the bar
[PHP]
<td width="<?php echo ($cellwidth); ?>" height="17" bgcolor="yellow" onMouseOver="this.style.background ='red'"
onMouseOut="this.style.background='yellow'" 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();" style="cursor: pointer;"></td>
[/PHP]
Stuck..
nma
8 2355
You can set a variable onclick which you can test onmouseover.
You could use a custom attribute to know which are selected..
Toggle color on/off with mouseover and mouseout events included.. Example provided -
<table>
-
<tr>
-
<td
-
onmouseover="if (this.getAttribute('selected')==null) { this.setAttribute('selected', ''); } if (this.getAttribute('selected')=='') { this.style.color = '#ff0000'; }"
-
onmouseout="if (this.getAttribute('selected')=='') { this.style.color = ''; }"
-
onclick="if (this.getAttribute('selected')!='') { this.setAttribute('selected', ''); this.style.color=''; } else { this.setAttribute('selected', 'true'); this.style.color='#ff0000'; }"
-
style="cursor: pointer;">
-
Blah
-
</td>
-
</tr>
-
</table>
-
I made this sample with font color rather than background color... you can change it.
You could use a custom attribute to know which are selected..
Toggle color on/off with mouseover and mouseout events included.. Example provided -
<table>
-
<tr>
-
<td
-
onmouseover="if (this.getAttribute('selected')==null) { this.setAttribute('selected', ''); } if (this.getAttribute('selected')=='') { this.style.color = '#ff0000'; }"
-
onmouseout="if (this.getAttribute('selected')=='') { this.style.color = ''; }"
-
onclick="if (this.getAttribute('selected')!='') { this.setAttribute('selected', ''); this.style.color=''; } else { this.setAttribute('selected', 'true'); this.style.color='#ff0000'; }"
-
style="cursor: pointer;">
-
Blah
-
</td>
-
</tr>
-
</table>
-
I made this sample with font color rather than background color... you can change it.
Hi iam_clint
I'm correcting the codes like below..there is red color on the cell once I mouseout but it remains many red color appear depending on as many times I click on the cell.
What is wrong with the code?
Thanks
[PHP]
<td width="<?php echo ($cellwidth); ?>" height="17" bgcolor="#00ff00" onmouseover="if (this.getAttribute('selected')==null) { this.setAttribute('selected', ''); } if (this.getAttribute('selected')=='') { this.style.background = '#ff0000'; }" onmouseout="if (this.getAttribute('selected')=='') { this.style.background = ''; }" onclick="if (this.getAttribute('selected')!='') { this.setAttribute('selected', ''); this.style.background=''; } else { this.setAttribute('selected', 'true'); this.style.background='#ff0000'; } "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(); " style="cursor: pointer;"></td>
[/PHP]
I don't fully understand your english... are you trying to make it so only 1 cell can be selected at a time?
I don't fully understand your english... are you trying to make it so only 1 cell can be selected at a time?
Sorry for my poor explaination..
Yes I want it only at one time cell selected (say red color)..then when user click at another cell that current cell will be selected and the previous cell back to original color
It is actually a timeline bar...
p/s the code you give is correct in terms of highlighted number of click user made on the timeline show red colored cell appear along the timeline/cells
Please help..
so you need to make a function for onclick.. in this function you iterate through all cells..
Example -
function resetHighlight() {
-
var ex=document.getElementById("tablebody").getElementsByTagName("TD");
-
for (var i=0; i<ex.length; i++) {
-
if (ex[i].getAttribute("selected")!="") {
-
ex[i].style.background="";
-
ex[i].setAttribute("selected", "");
-
}
-
}
-
}
-
-
function highlight(obj) {
-
resetHighlight();
-
obj.setAttribute("selected", "true");
-
obj.style.background="#FF0000";
-
}
-
so you need to make a function for onclick.. in this function you iterate through all cells..
Example -
function resetHighlight() {
-
var ex=document.getElementById("tablebody").getElementsByTagName("TD");
-
for (var i=0; i<ex.length; i++) {
-
if (ex[i].getAttribute("selected")!="") {
-
ex[i].style.background="";
-
ex[i].setAttribute("selected", "");
-
}
-
}
-
}
-
-
function highlight(obj) {
-
resetHighlight();
-
obj.setAttribute("selected", "true");
-
obj.style.background="#FF0000";
-
}
-
Hi iam_clint,
But how am I going to insert in my original coding..does this function need to be declare somewhere in the beginning of my codes.
At the moment in my original codes when onClick happen it will get some event (video keyframe list). Can I combine this two event (the code you give above + the one in my original codes) within one single onClick lines of codes? -
-
........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();"...........
Yes, it's relatively easy to combine. Move all the onclick code into its own function. I see that you're using PHP code within the onclick, so make the function generic and pass the PHP values as arguments to the function.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt Adams |
last post by:
As well known I could specify the text color in the body tag like:
<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>
What I want to achieve now is that always (!) the text of the last visited...
|
by: |
last post by:
Just about finished with an include modual that allows a user to select
a color. Completely dynamic. all you have to do is include the script and
run the main trigger script.
One problem with...
|
by: RobG |
last post by:
I have a function whose parameter is a reference the element that called it:
function someFunction(el)
{
...
}
The function is assigned to the onclick event of some elements in the
HTML...
|
by: mrajanikrishna |
last post by:
Hello,
I am developing an application in which the user has to select his
choice of colors and displaying the images with that color. How can I
display color palette to the user and return the...
|
by: emailseshu |
last post by:
Hi,
Iam trying to check the Client Side CallBack Feature in ASP.NET
Iam able to call th RaiseCallbackEvent from the Client Side Javascript
Function but when I go to the debug mode to check the...
|
by: pleaseexplaintome_2 |
last post by:
using the code below (some parts not included), I create a new excel
workbook with spreadheets.
I then want to delete a spreadsheet, but a reference remains open and
excel stays in task manager...
|
by: querry |
last post by:
Hi all,
I am having a table and I am trying to color the border of a cell when it is clicked. Here is what I use as my javascript.
function cellColor(tcid, e)
{
var...
|
by: rathour |
last post by:
<?php
session_start();
require_once('db.php');
include('functions.php');
$user = get_username ( $_SESSION );
//if ( $_SESSION ):
checkLogin ( '1 2' );
?>
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
| |