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
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