Naming DOM Created Fields and Internet Explorer
Join the Discussion
Among its many quirks and bugs, Internet Explorer omits support for one of the most important attributes that you will need to add in your code to be able to update the web page to include form content. Internet Explorer does not allow you to add a name attribute to any of your form fields after the tag itself is created.
All other browsers except for Internet Explorer provide two ways to name a form field. These are:
Internet Explorer does provide a way to add a name to a tag but you have to do it when actually creating the tag rather than afterwards. As well as supporting the standard createElement command where you just specify the type of element you want to create, Internet Explorer also allows you a second way to use that command where you can specify as many attributes as you like within the command itself as long as you define the content as a valid element. We can therefore define an input field and give it a name in Internet Explorer like this:
Note that we can do the same to add a name to any tag but if the tag is one that needs to be closed (eg. a paragraph) then you also need to include the closing tag (but not the content) in the command as well, eg.
var newNode =
var newNode = document.createElement("input");
newNode.name = myname;
/* @end @*/
We can of course then add as many other attributes as the field requires following this code and have the same code apply to all web browsers as Internet Explorer only dislikes following the standards for the name attribute.