Form length attribute
Definition and Usage
length
The property returns the number of elements in the form.
Instance
Example 1
Return the number of elements in the form:
var x = document.getElementById("myForm").length;
Example 2
Return the value of each element in the 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;
Syntax
formObject.length
Technical Details
Return Value: | Numbers, indicating the number of elements in the form. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |