Form length Property
Example
Return the number of elements in a form:
var x = document.getElementById("myForm").length;
Try it Yourself »
Description
The length property returns the number of elements in a form.
Browser Support
Property | |||||
---|---|---|---|---|---|
length | Yes | Yes | Yes | Yes | Yes |
Syntax
formObject.length
Technical Details
Return Value: | A Number, representing the number of elements in the form |
---|
More Examples
Example
Return the value of each element in a form:
var x = document.getElementById("myForm");
var txt = "";
var i;
for (i = 0; i < x.length; i++) {
txt = txt + x.elements[i].value + "<br>";
}
document.getElementById("demo").innerHTML = txt;
Try it Yourself »
❮ Form Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.