Sets or retrieves the name of the object.
![]() |
Syntax
| HTML | <element name="p" ... > |
|---|---|
| JavaScript | |
Property values
Type: String
the name.
Standards information
- Document Object Model (DOM) Level 1 Specification, Section 2.5.5
- HTML 4.01 Specification, Section 17.3
Remarks
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.
JavaScript 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.
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]);
See also
- attribute
- button
- form
- 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
Build date: 11/28/2012
