M
mitch
It seems like if you create an element dynamically with createElement()
and then try to get it later with getElementsByName()
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.getElementById("theSpan");
var cb = document.createElement("input");
cb.type = "checkbox";
cb.name = "theCheckbox";
s.appendChild(cb);
var names = document.getElementsByName("theCheckbox");
var nameStr = (names) ? names.length : "null";
alert("names=" + nameStr);
}
</SCRIPT>
<SPAN ID="theSpan" onClick = "addCB()" > click here </SPAN>
</body>
</html>
and then try to get it later with getElementsByName()
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.getElementById("theSpan");
var cb = document.createElement("input");
cb.type = "checkbox";
cb.name = "theCheckbox";
s.appendChild(cb);
var names = document.getElementsByName("theCheckbox");
var nameStr = (names) ? names.length : "null";
alert("names=" + nameStr);
}
</SCRIPT>
<SPAN ID="theSpan" onClick = "addCB()" > click here </SPAN>
</body>
</html>