I'd held off on posting here since I don't feel I have the skill level yet to give back to the community, but this one has me totally stumped.
I have a recursive JavaScript function that appends a counter to the end of all id and name elements in a node tree. The function works in FF, Chrome, Safari, and IE9, but not IE8.
function counterAppend(nodes,counter)
{
var newField = nodes.childNodes;
for (var i=0;i<newField.length;i++)
{
var theName = newField[i].name;
if (theName)
{
newField[i].name = theName + counter;
}
var theId = newField[i].id;
if (theId)
{
newField[i].id = theId + counter;
}
//recursive part
if(newField[i].childNodes.length>0)
{
newField[i] = counterAppend(newField[i],counter);
}
}
return nodes;
}
I get the error on the line: newField[i] = counterAppend(newField[i],counter);
In debug, it says: Breaking on JS runtime error - Object doesn't support this property or method
What is different between IE8 and the other browsers, and how can I modify this to work around the error?