HBCMS更多的中文手册参考:

getElementsByName Method

DHTML文档教程

Retrieves a collection of objects based on the value of the name attribute.

dhtml语法

collobjects = document.getelementsbyname(snamevalue)

parameters

sNameValue Required. Stringthat specifies the value of a NAME attribute.

Return Value

Returns a collection of objects with the same NAME attribute value.

Remarks

When you use the getElementsByName method, all elements in the document that have the specified NAME or id attribute value are returned.

elements that support both the name and the id attribute are included in the collection returned by the getelementsbyname method, but not elements with a name?a href="../properties/expando.html">expando.

DHTML代码范例

This example uses the getElementsByName method to return a collection of input type=text elements with the specified name attribute value, firstname.

<SCRIPT>
function fnGetNames(){
// Returns a collection with 2 INPUT type=text elements.
var aInput=document.getElementsByName("firstName");
}
</SCRIPT>
<INPUT TYPE="text" NAME="firstName">
<INPUT TYPE="text" NAME="firstName">
<INPUT TYPE="button" VALUE="Get Names" onclick="fnGetNames()">

是否符合公共标准

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

Applies To

document

更多语法参考

About the W3C Document Object Model