Form length Property
Example
Return the number of elements in a form:
var x = document.getElementById("myForm").length;
The result of x will be:
3
Try it yourself »
Definition and Usage
The length property returns the number of elements in a form.
Browser Support
The length property is supported in all major browsers.
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