JavaScript Reference/Javascript Collections/elements
Содержание
"elements" Example
<html>
<body>
<script language="JavaScript">
function function1() {
var m = document.all.myForm.elements(2);
alert("It is a "+"""+m.type+"""+" element");
}
</script>
<form id="myForm" method="post" action="">
<input type="text">
<textarea></textarea>
<input type="checkbox" value="checkbox">
<select></select>
<input id="myB"
type="button"
value="What is the third element in the above form?"
onclick="function1();">
</form>
</body>
</html>
"elements" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<form> |
+----------------+--------------------------------------------------------------+
"elements" JavaScript properties and JavaScript methods
JavaScript properties and JavaScript methods
item(), length, namedItem(), tags(), urns()
"elements" Syntax Parameters and Note
Note:
Returns an array of all <input> and <textarea> elements in <form> element.
This collection does not includes image <input>.
Syntax:
document.getElementById("formID").elements // returns all form elements
document.getElementById("formID").elements(param1, param2) // returns an individual
form element
document.all.formID.elements // IE only
document.all.formID.elements(param1, param2) // IE only
param1 Required; zero-based index
or the desired member"s id or name attribute.
param2 Optional; zero-based index for the result returned
if param1 matches more than one element.