Getting form References : Introduction : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Introduction »

 

Getting form References









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"







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Introduction