Information Technology Learning Centers

JavaScript 2

-

Forms, Loops, String Conversion, and Formatting Text

Raymond J. Kimball


Project Manager, TechLEAP
Information Technology Institute

  1. Working with Forms
  2. Conditions
  3. Loops
  4. Formatting Text for Display
  5. Converting Strings

I. Working with Forms. Web forms can involve the interplay of three different code structures to present an "interactive" format recognized by users:

We will explore in this section the third of those three -- the JavaScript used for code validation. We will work with the form, and so you will see the HTML underlying the code, but we will not spend time explaining how to set up HTML forms. Neither shall we discuss in detail the CGI/Perl Script code which might be used to capture, store, and process the information involved.

So, let's set up a form and see how it the information typed in by the client could be validated prior to submission by client-side JavaScript inserted in the form.

  1. Select and Go Navigation
  2. Verifying Passwords
  3. Selecting Menu Items
  4. Radio Buttons
  5. Setting One Field with Another
  6. Validating Email Addresses
  7. Verifying zip codes
  8. The whole enchilada

II. Conditions.

Conditions are "if...then...else statements, which test whether a condition is true or false, or whether a property has a certain value. See the following discussion of conditions, and view many of the codes we have studied.

III. Loops.

Loops scroll through a set of related information (or an Array) using a

IV. Formatting Text.

Formatting text can be done inside the paramter parentheses () of the write method. You simply "write" the standard HTML tags you want to surround the statements. See the Conditions sample code above. This can also be done to format photographs, which we'll discuss next week. But, if you want, you can look ahead to the slide show coding on my web site athttp://www.cocanal.com.

V. Converting Strings.

See the discussion of concatenation in the Javascript basics essay.