473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

getElementsByName doesn't seem to work in IE

banning
42
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


Expand|Select|Wrap|Line Numbers
  1. //THIS DOESN'T WORK
  2. var vertClicker=0;
  3. function vertColor(id){
  4.     var tds = document.getElementsByName(id);
  5.     for(var i = 0; i < tds.length; ++i )
  6.     {
  7.         if(vertClicker==0 && tds[i].style.backgroundColor=='' || vertClicker==1 && tds[i].style.backgroundColor==''){
  8.             vertClicker=1;
  9.         }else if(vertClicker==0 && tds[i].style.backgroundColor!='' || vertClicker==1 && tds[i].style.backgroundColor!=''){
  10.             vertClicker=0;
  11.         }
  12.         if (vertClicker==1){
  13.             tds[i].style.backgroundColor='#66FFCC';
  14.         }else{
  15.             tds[i].style.backgroundColor='';
  16.         }
  17.     }
  18. }
  19.  
  20. //THIS WORKS 
  21. var horzClicker=0;
  22. function horzColor(horzClick){
  23.     if(horzClicker==0 && document.getElementById(horzClick).style.backgroundColor=='' || horzClicker==1 && document.getElementById(horzClick).style.backgroundColor==''){
  24.         horzClicker=1;
  25.     }else if(horzClicker==0 && document.getElementById(horzClick).style.backgroundColor!='' || horzClicker==1 && document.getElementById(horzClick).style.backgroundColor!=''){
  26.         horzClicker=0;
  27.     }
  28.     if (horzClicker==1){
  29.         document.getElementById(horzClick).style.backgroundColor='#B7EFFF';
  30.     }else{
  31.         document.getElementById(horzClick).style.backgroundColor='';
  32.     }
  33. }
  34.  
Sep 5 '07 #1
5 1323
Death Slaught
1,137 1GB
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


Expand|Select|Wrap|Line Numbers
  1. //THIS DOESN'T WORK
  2. var vertClicker=0;
  3. function vertColor(id){
  4.     var tds = document.getElementsByName(id);
  5.     for(var i = 0; i < tds.length; ++i )
  6.     {
  7.         if(vertClicker==0 && tds[i].style.backgroundColor=='' || vertClicker==1 && tds[i].style.backgroundColor==''){
  8.             vertClicker=1;
  9.         }else if(vertClicker==0 && tds[i].style.backgroundColor!='' || vertClicker==1 && tds[i].style.backgroundColor!=''){
  10.             vertClicker=0;
  11.         }
  12.         if (vertClicker==1){
  13.             tds[i].style.backgroundColor='#66FFCC';
  14.         }else{
  15.             tds[i].style.backgroundColor='';
  16.         }
  17.     }
  18. }
  19.  
  20. //THIS WORKS 
  21. var horzClicker=0;
  22. function horzColor(horzClick){
  23.     if(horzClicker==0 && document.getElementById(horzClick).style.backgroundColor=='' || horzClicker==1 && document.getElementById(horzClick).style.backgroundColor==''){
  24.         horzClicker=1;
  25.     }else if(horzClicker==0 && document.getElementById(horzClick).style.backgroundColor!='' || horzClicker==1 && document.getElementById(horzClick).style.backgroundColor!=''){
  26.         horzClicker=0;
  27.     }
  28.     if (horzClicker==1){
  29.         document.getElementById(horzClick).style.backgroundColor='#B7EFFF';
  30.     }else{
  31.         document.getElementById(horzClick).style.backgroundColor='';
  32.     }
  33. }
  34.  
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
Sep 5 '07 #2
acoder
16,027 Expert Mod 8TB
Show the code for the table.
Sep 6 '07 #3
banning
42
Show the code for the table.
it is a VERY BIG table so here is just a link to it

http://www.doughxpress.com/staging/d...ilsElec?Wid=76

thank you guys for the help so far :)
Sep 6 '07 #4
acoder
16,027 Expert Mod 8TB
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.
Sep 7 '07 #5
banning
42
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 :)
Sep 7 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: simon | last post by:
<html> <head> <script language="vbscript"> sub window_onload msgbox document.getElementsByName("name1").length end sub </script> </head> <body> <div name="name1">testDiv</div>
21
by: briggs | last post by:
<html> <head> <script> /* AddChild */ function ac() { var c; var p = document.getElementById("p"); for (var i = 0; i < 5; i++) { c = document.createElement("DIV"); // Create 'div' element.
2
by: André Wagner | last post by:
I'm trying to get all the "divs" that have a given NAME using getElementsByName(). For example, the following code: <html> <head> <script type="text/javascript"> function on_load() { var...
22
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I...
4
by: Otto Wyss | last post by:
I've tried to access the value of a selected option through the following getSelectValue function, passing the name of the select function getSelectValue (name) { var sel =...
2
by: tsalm | last post by:
Hi everybody, I need to get a element create dynamically by its name. It's ok for FF, but on IE, getElementsByName return "undefined". I create this code but not sure that it can work on older...
2
by: zephyr | last post by:
Hi, I have a hidden field in my form: <input type="hidden" name="checkBoxesCollection" value=""> If I submit the form I call a javascript function: function storeCheckboxFieldNames(theForm){...
1
by: Sebarry | last post by:
Hi, Can anyone tell me how to use getElementsByName to retrieve the length of a HTML select input type? I've tried document.getElementsByName("selectName").options.length but it doesn't work. ...
2
Frinavale
by: Frinavale | last post by:
I'm attempting to intercept the click event for RadioButons in an attempt to ask the user for confirmation of their action. I determined that Internet Explorer does not reset the previous...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.