NAME Attribute | name Property

Internet Development Index

Sets or retrieves the name of the object.

What's New for Microsoft® Internet Explorer 6

This property now applies to the attribute object.

Syntax

HTML<ELEMENT NAME = sName... >
Scriptingobject.name [ = sName ]

Possible Values

sNameString that specifies or receives the name.

The property is read/write. The property has no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

Remarks

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, not the displayed value, is the one submitted with the form.

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.

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.

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>");

Standards Information

This property is defined in HTML 3.2 Non-Microsoft link and is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 Non-Microsoft link.

Applies To

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