JavaScript

Background
Inserting in an HTML file, Separate File
Dialog Boxes
Functions and User Input

see source code by clicking on the lessons, and selecting source from the view menu option.

Background

What is JavaScript?
Java Script is a scripting language that allows web designers to create dynamic and interactive web pages.

What is a Scripting Language and how it different from a Programming Language?
"Scripting languages combine tools from programming languages to make them more concise and usable." (Source: JavaScript for the www)

How powerful or useful is JavaScript?
JavaScript allows for
  • Managing User Interactivity
  • Display date and related info
  • Get user info such as screen size, browser type, user plug-ins
  • Confirm User Inputs
  • Alert, Prompt Users
  • Managing windows
  • Dynamic Web Behavior
Why learn JavaScript?
If you are a web designer, JavaScript allows you to find information about the users, request and process information during the user's visit (real time).

What kind of background is needed to learn JavaScript?
My knowledge of HTML, C, Java , and CGI helps learning JavaScript.

Do I need any special hardware or software?
No. Just the Browser and the notepad is sufficient.

What are the primary and helpful resources for learning JavaScript?
I will list them shortly.
| Top | | AJ Home |

Inserting in an HTML file, Separate File, Dialog Boxes

Lesson1- Inserting JavaScript in an HTML Document
The JavaScript is placed in the HTML page with in the script tag. The hide tag hides the JavaScript from browsers that are not enabled to process them. Also note that /* */ and // can be used to include comment within the JS.

Lesson2- Including JavaScript from another file, javas2.js
Note that the file containing the script does not have the script tag, and is saved with extension js. In this case, it is just a write statement to the document.


| Top | | AJ Home |

Dialog Boxes

Lesson3-Dialog Boxes
We are all familiar with Dialog Boxes that pops up to warn (Alert), to confirm and request for selection (Prompt). The Alert Dialog Box does not return any value, only an ALERT. The Confirm Dialog Box returns true or false, and the Prompt Dialog Box returns a value or a variable. The web designer can use this information.

| Top | | AJ Home |

Functions and User Input

Lesson4-User Inputs and Functions-Eco the input in a another page
The concept of functions in JavaScript is similar to that of C. The function has a name, takes in the arguments, and executes the statements when called upon. The function is first defined, then used. Also, note that the functions are defined in the header sections of the html page.

Usually, the user information is gathered using HTML Forums and process using CGI scripts. JavaScript can assist in gathering and processing user inputs. After, the user has input the information or selection, some sort of action need to be performed. On of the way is to call a function described with in the JavaScript to perform the necessary action.

In this example, the user enters some information in the text area. That information is echoed in another page. Note that the information is not saved. Also, the other page does not contain a link back to the original page.

Lesson5-User Input-Pass info to the functions
In this example, a value is passed to the function. Note that the input value need not be passed, rather can be directly accessed.

| Top | | AJ Home |