Forms
JavaScript topics covered:
  1. form attributes
    • action
    • method
    • name
  2. Basic form tags
    • <input>
    • <select>
    • <option>
    • <textarea>
  3. Validate text Data

Class Demos:

  1. in class demo form fields
  2. in class demo display form fields
  3. in class demo edit fields
  4. in class demo drop down list
  5. in class demo multiple forms
  6. in class demo this keyword and form fields


Gathering information from the user.

Forms basically are used to gather information from the user. Just like most HTML tags, forms have a two sided <form> tag. As we have discussed in class, some objects are actually arrays of other objects. The form object is one of them. There can be several forms on a document. To refer to the first form you can use the statement "document.forms[0]". The form itself has an array of elements. You can reference each element on the form using it's elements[] array. For example, the form listed below, to reference the value of the first field we could use "document.forms[0].elements[0].value". Using JavaScript we can reference all the attributs and elements on the a form. The <form> tag has several attributes:

  1. form attributes
  2. Basic form tags
  3. ways to submit the form The submit() method is used to submit a form without the use of a submit <input> tag. The reset() method is used to reset a form without the use of a reset <input> tag. Use an event handler to run a function that validates the form. click here to see the demo.