It seems like if you create an element dynamically with createElement()
and then try to get it later with getElementsByNa me()
it's found in Firefox but not in IE. Here's an example program.
Is there something wrong with the program, or is there another way to
get elements that have been created dynamically? Thanks.
<html>
<body>
<SCRIPT>
function addCB(){
var s = document.getEle mentById("theSp an");
var cb = document.create Element("input" );
cb.type = "checkbox";
cb.name = "theCheckbo x";
s.appendChild(c b);
var names = document.getEle mentsByName("th eCheckbox");
var nameStr = (names) ? names.length : "null";
alert("names=" + nameStr);
}
</SCRIPT>
<SPAN ID="theSpan" onClick = "addCB()" > click here </SPAN>
</body>
</html>