Hi all, I hope this is on topic, please ignore it if not, I have a small Jscript problem that shouldn't be hard to sort out, but I am not great with these things...
I have a script that adds colours to a all the columns in a table. It works fine, the only problem is, it is trying to apply the code to all pages, when the table is only on a couple. So when I am viewing all other pages, it comes up with this error: document.getElementById(tableID) has no properties So, what I would like to do, is add a checker to the script to see if the table actually exists before doing the rest of the code. Unfortunately, I am a novice to this and I've been stuffing around for a while and can't get it to work. Here is the teh script, it is worth mentioning that this is the only table on the site, so that may help with the re-working of the code, although it would be nice to have a checker that looks for the specific table id. Thanks in advance: // script to add alternating table background colours var colors=["#E5D9DB","#C5D3D8","#DBCBBE","#E9DBC7","#D4E0E0","#C5CEC7"]; function alternateRows(tableID,numberOfColors,colorArray){ var trs=document.getElementById(tableID).getElementsByTagName("TD"); len=trs.length; var myColors=colorArray.slice(0,numberOfColors); while(len--){ trs[len].style.backgroundColor=colors[len%myColors.length]; } } // add onload event addLoadEvent(function() { alternateRows("caseStudiesTable",6,colors); } ); ******************************************************************* List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] *******************************************************************