PDA

View Full Version : Flashing Table Border: Need Variation



Single_Tasker
05-03-2006, 07:49 PM
Flashing Table Border Script
http://www.dynamicdrive.com/dynamicindex11/other2.htm

I've pasted the DD script below.

The script and DD example page are set up to flash the border of ONE table. I have 4 seperate tables located at different places on my webpage. I have pasted the script 4 seperate times then changed the function and ID of each script- and its corresponding table- to flash the borders on the 4 tables. All of the borders are doing the exact same thing with the exact colors- which is what I want.

Can I use the script just ONCE- with modifications- that allow it to do the exact same thing on the 4 tables- rather than using the entire script 4 times? If so- be gentle- I'll need to see the fixed code.

////////////////////
Flashing Table Border Script
http://www.dynamicdrive.com/dynamicindex11/other2.htm

<table border="0" width="280" id="myexample" style="border:5px solid green">
<tr>
<td>Insert anything you want into this table.<br>Insert anything you want into this table.<br>Insert anything you want into this table.<br></td>
</tr>
</table>
<script language="JavaScript1.2">
<!--

/*
Flashing Table Border Script- Dynamic Drive (www.dynamicdrive.com)
Visit http://www.dynamicdrive.com for this script
Credit must stay intact for use
*/

//configure interval btw flash (1000=1 second)
var speed=500

function fla****(){
var crosstable=document.getElementById? document.getElementById("myexample") : document.all? document.all.myexample : ""
if (crosstable){
if (crosstable.style.borderColor.indexOf("green")!=-1)
crosstable.style.borderColor="red"
else
crosstable.style.borderColor="green"
}
}
setInterval("fla****()", speed)
//-->
</script>
//////////////////////////

Thanks,
Bill

Twey
05-03-2006, 08:05 PM
<script type="text/javascript">

/*
Flashing Table Border Script- &#169; Dynamic Drive (www.dynamicdrive.com)
Visit http://www.dynamicdrive.com for this script
Credit must stay intact for use
*/

//configure interval between flashes in milliseconds (1000=1 second)
var speed = 500;

var getTable = (function() {
var w3c = function(id) {
return document.getElementById(id);
}
var ie = function(id) {
return document.all[id];
}
var none = function(id) {
return false;
}
return (document.getElementById ? w3c : (document.all ? ie : none));
})();

function fla****() {
var crosstable = false;
for(var i=1;crosstable = getTable("flashtable" + i);i++) {
if (crosstable.style.borderColor.indexOf("green")!=-1)
crosstable.style.borderColor="red";
else
crosstable.style.borderColor="green";
}
}
setInterval("fla****()", speed);
</script>
Untested. Give your tables incremental IDs, such as, in this example: flashtable1, flashtable2, flashtable3, flashtable4...

Single_Tasker
05-04-2006, 02:12 AM
Works like a charm.

What can I say?... Yer Da Man!!!!!

Thanks a million,
Bill