HTML DOM elements Collection
Complete Form Object Reference
Definition and Usage
The elements collection returns an array containing each element in the form.
Syntax
formObject.elements[].property
|
Example
The following example outputs the value of all the form elements:
<html>
<body>
<form id="myForm">
Firstname: <input id="fname" type="text" value="Mickey" />
Lastname: <input id="lname" type="text" value="Mouse" />
<input id="sub" type="button" value="Submit" />
</form>
<p>Get the value of all the elements in the form:<br />
<script type="text/javascript">
var x=document.getElementById("myForm");
for (var i=0;i<x.length;i++)
{
document.write(x.elements[i].value);
document.write("<br />");
}
</script>
</p>
</body>
</html>
|
Try-It-Yourself Demos
Get
the value of all form elements
Complete Form Object Reference
|
|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|