Skip to content

Instantly share code, notes, and snippets.

@aarongustafson
Created July 25, 2010 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarongustafson/489588 to your computer and use it in GitHub Desktop.
Save aarongustafson/489588 to your computer and use it in GitHub Desktop.
function createElementWithName(type, name) {
var element;
// First try the IE way; if this fails then use the standard way
if (document.all) {
element =
document.createElement('< '+type+' name="'+name+'" />');
} else {
element = document.createElement(type);
element.setAttribute('name', name);
}
return element;
}
var oAnchor = document.createElement("<A NAME='AnchorName'></A>");
<<input name="company" /> id="company" maxlength="255" />
<INPUT id=company maxLength=255>
var inpt = document.createElement('input');
inpt.setAttribute('name', 'company');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment