getElementsByName doesn't seem to work in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • banning
    New Member
    • Aug 2007
    • 42

    getElementsByName doesn't seem to work in IE

    ok im sick and tired of browser compatibility, i had a question a while ago and someone was kind enough to help me out and figure out my solution and it worked... course i use the ever amazing firefox and of course it worked... unfortunately in my hast i forgot to check IE and the code for the vertClicker doenst appear to work in IE. i dont know if i have posted enough of the code or not but i hope you guys are able to help ... thanks in advance


    [CODE=javascript]
    //THIS DOESN'T WORK
    var vertClicker=0;
    function vertColor(id){
    var tds = document.getEle mentsByName(id) ;
    for(var i = 0; i < tds.length; ++i )
    {
    if(vertClicker= =0 && tds[i].style.backgrou ndColor=='' || vertClicker==1 && tds[i].style.backgrou ndColor==''){
    vertClicker=1;
    }else if(vertClicker= =0 && tds[i].style.backgrou ndColor!='' || vertClicker==1 && tds[i].style.backgrou ndColor!=''){
    vertClicker=0;
    }
    if (vertClicker==1 ){
    tds[i].style.backgrou ndColor='#66FFC C';
    }else{
    tds[i].style.backgrou ndColor='';
    }
    }
    }

    //THIS WORKS
    var horzClicker=0;
    function horzColor(horzC lick){
    if(horzClicker= =0 && document.getEle mentById(horzCl ick).style.back groundColor=='' || horzClicker==1 && document.getEle mentById(horzCl ick).style.back groundColor=='' ){
    horzClicker=1;
    }else if(horzClicker= =0 && document.getEle mentById(horzCl ick).style.back groundColor!='' || horzClicker==1 && document.getEle mentById(horzCl ick).style.back groundColor!='' ){
    horzClicker=0;
    }
    if (horzClicker==1 ){
    document.getEle mentById(horzCl ick).style.back groundColor='#B 7EFFF';
    }else{
    document.getEle mentById(horzCl ick).style.back groundColor='';
    }
    }
    [/CODE]
    Last edited by pbmods; Sep 5 '07, 10:10 PM. Reason: Changed [CODE] to [CODE=javascript].
  • Death Slaught
    Top Contributor
    • Aug 2007
    • 1137

    #2
    Originally posted by banning
    ok im sick and tired of browser compatibility, i had a question a while ago and someone was kind enough to help me out and figure out my solution and it worked... course i use the ever amazing firefox and of course it worked... unfortunately in my hast i forgot to check IE and the code for the vertClicker doenst appear to work in IE. i dont know if i have posted enough of the code or not but i hope you guys are able to help ... thanks in advance


    Code:
    //THIS DOESN'T WORK
    var vertClicker=0;
    function vertColor(id){
    	var tds = document.getElementsByName(id);
    	for(var i = 0; i < tds.length; ++i )
    	{
    		if(vertClicker==0 && tds[i].style.backgroundColor=='' || vertClicker==1 && tds[i].style.backgroundColor==''){
    			vertClicker=1;
    		}else if(vertClicker==0 && tds[i].style.backgroundColor!='' || vertClicker==1 && tds[i].style.backgroundColor!=''){
    			vertClicker=0;
    		}
    		if (vertClicker==1){
    			tds[i].style.backgroundColor='#66FFCC';
    		}else{
    			tds[i].style.backgroundColor='';
    		}
    	}
    }
    
    //THIS WORKS 
    var horzClicker=0;
    function horzColor(horzClick){
    	if(horzClicker==0 && document.getElementById(horzClick).style.backgroundColor=='' || horzClicker==1 && document.getElementById(horzClick).style.backgroundColor==''){
    		horzClicker=1;
    	}else if(horzClicker==0 && document.getElementById(horzClick).style.backgroundColor!='' || horzClicker==1 && document.getElementById(horzClick).style.backgroundColor!=''){
    		horzClicker=0;
    	}
    	if (horzClicker==1){
    		document.getElementById(horzClick).style.backgroundColor='#B7EFFF';
    	}else{
    		document.getElementById(horzClick).style.backgroundColor='';
    	}
    }
    Well for starters I would change your:

    vertClicker==0

    vertClicker==1

    to:

    vartClicker=="0 "

    and

    vertClicker=="1 "

    the reason for this is the the if...else etc. statements are looking for the variables 0 and 1 also i would do it to your:

    vertClicker=1;

    and

    vertClicker=0;

    Thanks, Death
    Last edited by Death Slaught; Sep 5 '07, 10:00 PM. Reason: typo

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Show the code for the table.

      Comment

      • banning
        New Member
        • Aug 2007
        • 42

        #4
        Originally posted by acoder
        Show the code for the table.
        it is a VERY BIG table so here is just a link to it



        thank you guys for the help so far :)

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          You've got Javascript errors, e.g. loadSelected() and Class are both not defined. In IE, it complains of Object Expected (which I presume to be loadSelected()) and Event being undefined.

          Comment

          • banning
            New Member
            • Aug 2007
            • 42

            #6
            interesting well thanks for the help i'll see what i can do with it... its odd that the code for the horizontal worked but not the vertical. Well at least odd to me but then again im not much of a JS person.

            Thanks for the help though :)

            Comment

            Working...