see when i do this in IE it comes out as 0
but when i do it in FIREFOX it comes out as 41
I think that IE has problems with tds and getElementsByNa me. A bit of testing shows that it just doesn't work. Give your table an id and try: [CODE=javascript]document.getEle mentById('table ID').getElement sByTagName("td" );[/CODE]
I think that IE has problems with tds and getElementsByNa me. A bit of testing shows that it just doesn't work. Give your table an id and try: [CODE=javascript]document.getEle mentById('table ID').getElement sByTagName("td" );[/CODE]
when i try that it turns the whole table the color... what im trying to accomplish is just turn an individual column one color. course you probably all ready know that but yea i tried it and it worked in firefox and ie like it should :)
when i try that it turns the whole table the color... what im trying to accomplish is just turn an individual column one color. course you probably all ready know that but yea i tried it and it worked in firefox and ie like it should :)
no its not working... ie just sucks i guess... when i do what you posted it just turns the whole table a colour... i dont want that, i want to highlight just one column...
Heres a sample i made for you highlighting rows and cols without using names and works in firefox and ie. To use the code you will need to change your table accordingly.
[CODE=javascript]
<script>
vertColor="#66f fcc"
horzColor="#b7e fff";
function vertClick(col, tbl) {
var color="";
var table = document.getEle mentById(tbl);
var entireRow=table .getElementsByT agName("tr");
var curColor = entireRow[0].getElementsByT agName("td")[col].style.backgrou ndColor;
for (i=0; i<entireRow.len gth; i++) {
curEle = entireRow[i].getElementsByT agName("td")[col];
if (curEle.getAttr ibute("vert")== null || curEle.getAttri bute("vert")==" false") { curEle.setAttri bute("vert", "true"); color = vertColor; } else { curEle.setAttri bute("vert", "false"); color=""; }
if (color=="" && curEle.getAttri bute("horz")==" true") { curEle.style.ba ckgroundColor=h orzColor; } else { curEle.style.ba ckgroundColor=c olor; }
}
}
This is the same thing except theres an intersecting color.
[CODE=javascript]
<script>
/* Javascript written by iam_clint */
vertColor="#66f fcc";
horzColor="#b7e fff";
intersectColor= "#aa22f0";
function vertClick(col, tbl) {
var color="";
var blnColSpan = false;
var table = document.getEle mentById(tbl);
var entireRow=table .getElementsByT agName("tr");
for (i=0; i<entireRow.len gth; i++) {
curEle = entireRow[i].getElementsByT agName("td")[col];
for (b=0; b<entireRow[i].getElementsByT agName("td").le ngth; b++) {
colspan = entireRow[i].getElementsByT agName("td")[b].getAttribute(" colspan");
if (colspan!=null && colspan!=1) { blnColSpan = true; }
}
if (!blnColSpan) {
if (typeof(curEle) =="object") {
if (curEle.getAttr ibute("vert")== null || curEle.getAttri bute("vert")==" false") { curEle.setAttri bute("vert", "true"); color = vertColor; } else { curEle.setAttri bute("vert", "false"); color=""; }
if (curEle.getAttr ibute("horz")== "true" && curEle.getAttri bute("vert")==" true") { curEle.style.ba ckgroundColor=i ntersectColor; } else if (curEle.getAttr ibute("vert")== "false" && curEle.getAttri bute("horz")==" true") { curEle.style.ba ckgroundColor=h orzColor; } else { curEle.style.ba ckgroundColor=c olor; }
}
}
blnColSpan = false;
}
}
Comment