I keep tripping myself up with this one, IE is unable to set the name attribute for any dynamically created DOM nodes. It doesn’t matter if you clone an existing node, or create a new one, IE won’t set the name attribute.
Have a look at this example:
var newCheckbox = document.createElement('input');
newCheckbox.setAttribute(’type’, ‘checkbox’);
newCheckbox.setAttribute(’name’, x[i].name);
newCheckbox.setAttribute(’value’, ‘0′);
newCheckbox.setAttribute(’checked’, ‘checked’);
x[i].parentNode.appendChild(newCheckbox);
Will result in a new input element with no name attribute. The only way I’ve found to counter this, that works in both IE & Firefox is to use innerHTML.
var newCheckbox = document.createElement("span");
newCheckbox.innerHTML =”[input name='" + x[i].name + “‘ type=’checkbox’ value=’0′ checked=’checked’]”;
x[i].parentNode.appendChild(newCheckbox);
Is there a better way? I’d be interested to hear about any other solutions that might work.
-S



