Hi guys ...

I have the following JS code:

Code:
function buildElement(theLabel,name,msg)
{
    killElement('p_source','details');
    var parent = document.getElementById('p_source');
    
    var newPara     = document.createElement('p');
    newPara.id         = "details";
    var newLabel     = document.createElement('label');
    var newText     = document.createTextNode(msg);
    newLabel.appendChild(newText);
    newPara.appendChild(newLabel);
    
    var newInput     = document.createElement('input');    
    newInput.id     = "source_details";
    newInput.name     = "source_details";
    newInput.className     = "text";        

    newPara.appendChild(newInput);
    
    insertAfter(parent, newPara, theLabel);
}
Basically, it builds a new paragraph, along with a lable and text input field, the calls the insertAfter function to insert it into the document.

The insert after function I am using is as follows:

Code:
function insertAfter(parent, node, referenceNode) {
    parent.insertBefore(node, referenceNode.nextSibling);
}
Everything works fine in Safari (Mac) and Firefox but it fails in IE 6 and Ie 7.

The oh-so helpful error messages i get from IE, tells me the following:
Line: 271
Char: 2
Error: Invaild Argument
Code: 0
Now, looking at that, line 271 in my script would be the closing brace of the insertAfter function.

Does anybody know what could be causing this? Like I say, FF's error console and Firebug are not throwing up any errors.

Cheers,
D