Sets or retrieves the name of the object.
Syntax
| HTML | <ELEMENT NAME
= sName... >
|
|---|
| Scripting | [ sName = ] object.name |
|---|
Possible Values
| sName | String that
specifies or receives the name. |
The property is read/write.
The property has no default value.
DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, see About Dynamic Properties.
Remarks
Internet Explorer 8 and later. In IE8 mode, dynamically setting the name attribute on an input type=radio button correctly applies that button to the same named group. For more information on IE8 mode, see Defining Document Compatibility.
When submitting a form, use the name property to bind the value of the control. The name is not the value displayed for the input type=button, input type=reset, and input type=submit input types. The internally stored value is submitted with the form, not the displayed value.
Microsoft JScript allows the name to be changed at run time. This does not cause the name in the programming model to change in the collection of elements, but it does change the name used for submitting elements.
Internet Explorer 8 and later can set the NAME attribute at run time on elements dynamically created with the createElement method. To create an element with a NAME attribute in earlier versions of Internet Explorer, include the attribute and its value when using the createElement method.
In Microsoft Internet Explorer 6 and greater, this property applies to the attribute object.
Examples
The following example shows how to set the NAME attribute on a dynamically created A element.
var oAnchor = document.createElement("<A NAME='AnchorName'></A>");
The following example shows how to set the NAME attribute on a dynamically created A element. This example assumes that ppvDocument is a valid IHTMLDocument2 interface pointer, and ppvElement is a valid IHTMLElement interface pointer.
ppvDocument->createElement(CComBSTR("<A NAME='AnchorName'></A>"), &ppvElement)
The following example shows how to set the NAME dynamically on objects (option buttons) created with the createElement method.
var inp = document.createElement('input');
inp.setAttribute('type', 'radio');
inp.setAttribute('name', 'Q'+count);
inp.setAttribute('value', answers[i]);
This feature requires Windows Internet Explorer 7 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
Standards Information
This property is defined in
HTML 3.2
and
is defined in
World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1
.
Applies To
|
Attr Constructor,
A,
APPLET,
attribute,
BUTTON,
EMBED,
FORM,
IMG,
INPUT type=button,
INPUT type=checkbox,
INPUT type=file,
INPUT type=hidden,
INPUT type=image,
INPUT type=password,
INPUT type=radio,
INPUT type=reset,
INPUT type=submit,
INPUT type=text,
LINK,
MAP,
OBJECT,
RT,
RUBY,
SELECT,
TEXTAREA,
HTMLAnchorElement Constructor,
HTMLButtonElement Constructor,
HTMLEmbedElement Constructor,
HTMLFormElement Constructor,
HTMLImageElement Constructor,
HTMLInputElement Constructor,
HTMLMapElement Constructor,
HTMLObjectElement Constructor,
HTMLSelectElement Constructor,
HTMLTextAreaElement Constructor |