Matt Kruse said on 19/04/2006 1:20 PM AEST:
ja****@gmail.com wrote:
Does anyone know why IE gives the error "'document.myForm.dummy' is
null or not an object" on the following page?
I've never investigated far enough to figure out the real root cause of this
problem in IE. But IE definitely does have problems accessing
dynamically-created inputs by name. Also, see the example below, which
illustrates that changing an input's name doesn't make it available under
the new name, but it is still available under the old name:
From MSDN:
"The NAME attribute cannot be set at run time on elements
dynamically created with the createElement method. To create
an element with a name attribute, include the attribute and
value when using the createElement method."
<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/name_2.asp>
Microsoft gives the following example of a createElement statement
(excuse wrapping):
var newRadioButton = document.createElement("<INPUT TYPE='RADIO'
NAME='RADIOTEST' VALUE='First Choice'>")
<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/createelement.asp>
They reference the W3C DOM 1 createElement method, which infers that
Microsoft's is standards compliant. Opinions on that may vary ;-)
If you attempt to add or modify the name attribute of an element in IE
using script, you can look at the generated source using innerHTML and
see that it isn't added or modified.
You can add/modify the ID attribute, but then you can only access it
using strictly formal syntax:
document.forms[formName].elements[elementName];
or less strict:
document.forms.formName.elements.elementName;
but not "loose":
document.formName.elementName;
--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>