Hi,
I need to use e.getelementsbytagname to pull background color and make it blink every one minute in table cell td between two colors.
Any help would be awesome!
9 9208 Dormilich 8,658
Recognized Expert Moderator Expert
I have this so far:
html: - <tr class='bus'>
-
<td>Europe</td>
-
<td>EU111</td>
-
<td title='One'>Country</td>
-
<td class='b_number'>1457</td>
-
<td class='notice'>Bus left</td>
-
</tr>
I want to make it so class='notice' td changes background color every 1min between two colors i define.
I think it should be simple few lines using e.getElementsByTagName() just not sure how to construct it.
Dormilich 8,658
Recognized Expert Moderator Expert
I think it should be simple few lines using e.getElementsByTagName() just not sure how to construct it.
why so difficult? you already have a class, thus document.getElementsByClassName() (ok, not in IE) should do the job.
already an idea, how to get the timing working?
I would need this to be done by td not by class.. would it be something like: -
var table = document.getElementsByClassName('notice')
-
var cells = table.getElementsByTagName("td");
-
for (var i = 0; i < cells.length; i++) {
-
status = cells[i].getAttribute("status");
-
if ( status == "open")
-
cells[i].getElementsByTagName('td').style.color='white';
-
else
-
cells[i].getElementsByTagName('td').style.color='black';
-
}
-
zorgi 431
Recognized Expert Contributor
I saw this problem and strait away i thought jQuery
This is how it can be done with jQuery: -
<script type="text/javascript" src="jquery.js"></script>
-
<script type="text/javascript">
-
-
$(function(){blinkOn()})
-
-
function blinkOn(){
-
$(".notice").css("background-color", "red");
-
setTimeout("blinkOff()", 2000);
-
}
-
-
function blinkOff(){
-
$(".notice").css("background-color", "white");
-
setTimeout("blinkOn()", 60000);
-
}
-
</script>
-
This example blinks red every 60 seconds for 2 seconds.
Dormilich 8,658
Recognized Expert Moderator Expert
note: - setTimeout(blinkOff, 2000);
zorgi 431
Recognized Expert Contributor
Thanks Dorm
Slightly more compact solution: -
$(function(){blinkOn(2000, 'red');})
-
function blinkOn(time, color){
-
$(".notice").css("background-color", color);
-
switch(time){
-
case 2000:
-
setTimeout("blinkOn(60000, 'white')", time);
-
break;
-
default:
-
setTimeout("blinkOn(2000, 'red')", time);
-
}
-
}
-
zorgi 431
Recognized Expert Contributor
aaaand one more :) -
$(function(){
-
time = 2000;
-
color = 'white';
-
setInterval(function(){
-
$(".notice").css("background-color", color);
-
switch(time){
-
case 2000:
-
time = 60000;
-
color = 'red';
-
break;
-
default:
-
time = 2000;
-
color = 'white';
-
}
-
}, time);
-
})
-
Spoiled for choice :)
Dormilich 8,658
Recognized Expert Moderator Expert
aaaand one more note: - setTimeout(blinkOn, time, 60000, 'white');
just to have it mentioned
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: LVande |
last post by:
SQLLY challenged be gentle --
Trying to create code that will drop a table using a variable as the
Table Name.
DECLARE @testname as char(50)
SELECT @testname = 'CO_Line_of_Business_' +...
|
by: Ralph Snart |
last post by:
Is there a way to alternate table row colors without using the
position() mod 2 trick? I'm in a series of nested xsl:for-each
elements, about 3 deep, and I want to alternate the table row
color...
|
by: Andre Arpin |
last post by:
I am new at sql so would appreciate some help
I have the name of a table in alocal variable is it possible to select this
table
DECLARE @name sysname
SET @name = 'tblSniffedItems'
PRINT...
|
by: Max |
last post by:
Hi,
I have the following problem. I want to insert records into one table
using the combination of two other tables. Here is a simplified
example: Let's say the first table has a column with...
|
by: dave |
last post by:
I need to add a column to a table using code.
The following works, but only for a new table. How should I change this to
alter an existing table?
Dim strConn
Dim Catalog As New...
| |
by: GL |
last post by:
Hi,
Is there a way to add a field to an existing table using a query of
some sort (without needing to manually add a field to the table). I
know how to do it with a make table query, but I have...
|
by: Nathan Sokalski |
last post by:
When editing an ASP Table, Visual Studio does not allow me to edit it in
Design View. This makes it harder to add elements, because I must add every
element either by using Design View to create...
|
by: Laphan |
last post by:
AAAAARRRRGGGGHHHH!!!
Everything appears to be great in doing a web-based editor using the
execCommands apart from the fact that there is no method to insert a table.
I've seen somebody suggest...
|
by: cb123 |
last post by:
Hello,
Please bear with me I'm new to t-sql.
I've had no luck trying to figure this out yet using sql code. I need to use an existing table (data dictionary) as input for creating a new table.
...
|
by: nabh4u |
last post by:
hi,
I am trying to insert multiple rows in a table using PL/SQL. I have two procedures and two tables. the first procedure gets the data from the source table, manipulates it and then sends the...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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: 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,...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |