X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Form length Property

Form Object Reference Form Object

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

Internet Explorer Firefox Opera Google Chrome Safari

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 Reference Form Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook