Getting form References : Introduction « Form « JavaScript Tutorial






First, use getElementById() and pass in the form's ID:

var oForm = document.getElementById("form1");

Alternately, you can use the document's forms collection and reference the form either by its position in the forms collection or by its name attribute:

var myForm = document.forms[0];               //get the first form
var myOtherForm = document.forms["formZ"];    //get the form whose name is "formZ"








10.1.Introduction
10.1.1.Form Basics
10.1.2.A form can contain any number of input elements:
10.1.3.Getting form References
10.1.4.Accessing form Fields
10.1.5.Form Field Commonalities
10.1.6.Change string to big, bold, fixed with form control
10.1.7.Change string to italics, small, strike with form control
10.1.8.Change string to subscript and superscript with form control