We help IT Professionals succeed at work.
Get Started

'name' is null or not an object

525 Views
Last Modified: 2012-06-27
Hello I continuously keep getting this error in IE, while everything works in FF. I am trying to rename elements while I swap rows. All my elements have IDs. All elements except for divs, do not have names, so I get all elements by tag name from a row and perform my processing. But here in IE it gives me a problem when I try to replace name, for elements where name is null, I have a condition to prevent making any change, but this error pops up at the condition. Is there any way around for this problem??
var row= document.getElementById(row.id);
var elems = row.getElementsByTagName('*');
var r = explodeArray(row.id, "_");
var vtLineNum = Number(r[1]);
var vtName = r[0];
	for(var i in elems)
	{
		if(elems!=null &&  elems[i]!=null && elems[i].id!=null && elems[i].id!='')
		{		
				document.write(elems[i].name+"<br>");
				elems[i].id = replaceNum(elems[i].id, vtLineNum);
				if(elems[i].name !=null && elems[i].name !='')
					{elems[i].name = replaceNum(elems[i].name, vtLineNum);}

				if(elems[i].id.match("div"+vtName+'_'))
					{					
					var children = document.getElementById(elems[i].id).childNodes;
						for(var i in children)		
						{	
							if(children[i].href != null)			
							{
							children[i].href = replaceNum(children[i].href, vtLineNum);
							}
						}			
					}				
		}
	}

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE