JavaScript Reference/Javascript Collections/forms

Материал из Web эксперт
Перейти к: навигация, поиск

"forms" Example

   <source lang="javascript">
   

<html> <body> <form name="form1" method="post" action=""><textarea></textarea></form>

<form name="form2" method="post" action="">

<input type="text">

</form>

<form name="form3" method="post" action=""><input type="radio"> <input type="checkbox"></form> <button onclick="alert(document.forms.length);">Number of forms in the page</button> </body> </html>


     </source>
   
  


"forms" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |document | +----------------+--------------------------------------------------------------+

     </source>
   
  


"forms" JavaScript properties and JavaScript methods

   <source lang="javascript">

JavaScript properties and JavaScript methods

item(), length, namedItem(), tags(), urns()


     </source>
   
  


"forms" Syntax Parameters and Note

   <source lang="javascript">

Note: Returns an array of all <form> elements in the document.

Syntax:

document.forms // returns all forms document.forms(param1, param2) // returns an individual form

   param1   Required; zero-based index or 
                      the desired member"s id or name attribute.
                      
   param2   Optional; zero-based index     
                      if param1 matches more than one element.
   
     
     </source>