Export (0) Print
Expand All
all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize
5 out of 36 rated this helpful - Rate this topic

name attribute | name property

Sets or retrieves the name of the object.

HTML 4.01 Specification, Section 17.3

Syntax

HTML<element name="p" ... >
JavaScript

p = object.name

Property values

Type: String

the name.

Standards information

Remarks

When you submit a form, use the name property to bind the value of the control.

The name is not the value that is 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.

When you submit 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 you to change the name 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 that you use for submitting elements.

Windows Internet Explorer 8 and later. In IE8 Standards mode, dynamically setting the name attribute on an input type=radio button correctly applies that button to the same named group. For more information about IE8 mode, see Defining Document Compatibility.

In Internet Explorer 8 and later versions, you can set the name attribute at run time on elements that are dynamically created with the createElement method. To create an element with a name attribute in earlier versions of Windows Internet Explorer, include the attribute and its value when you use the createElement method.

In Microsoft Internet Explorer 6 and later versions, 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.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/Dyn_Name_Sample.htm


 var inp = document.createElement("input");
	inp.setAttribute("type",  "radio");
	inp.setAttribute("name",  'Q'+count);
	inp.setAttribute("value", answers[i]);

See also

attribute
button
form
input type=button
input type=checkbox
input type=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
link
map
object
rt
ruby
select
textArea

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.