<%response.buffer=true%> <% Response.Expires = 0 %> JavaScript Intro

Example Files

Below are links to example files that we have built in class.  If You click on the file name, you can see an example of the file in action.  Click on the word SOURCE to open a word document showing the source code for the file.

File Name Function Notes/Source
Shows current year as part of page copyright.

Include this in a JS include file and keep all your pages up to date. SOURCE

Shows date in mm/dd/yyy format. Example of if/then syntax. SOURCE
Image/color/messages change based on hour of day. (Harnesses system clock) Demos if/else statement, document.bgColor, document.write.
Switches page content based on date (1-31, etc). Rotates content based on modulus. Demos switch statement, modulus operator.
Uses window.open to popup a page into a new window. Demos custom functions to vary window size, document location via anchor tags.
Demonstrates properties of the navigator object, and for/in looping example. Knowing the browser of the user can allow custom styles, etc.
Demonstrates use of onload event of the body tag to edit document elements. Write to the document 3 different ways in this example. Useful for both Assign 1 & 2!
Demonstrates use of userAgent property of the navigator object. Uses indexOf() method of string object to determine the type of browser currently viewing page. The tip of the iceberg of useable browser sniffing. Useful for Assign 2!
randomQuotes.htm Generates random quotes from an array built in JS. Uses an array as a data source. SOURCE
huey.htm A simple array example. A basis for next example (SplitNephews). SOURCE
SplitNephews.htm Splits a comma separated form element value in an array, and prints to the screen. Shows use of split function, and innerHTML. SOURCE
Demonstrates various ways to create a "rollover" image effect. As long as your images are pre-loaded, how you roll the images is up to you!
Determines current page to create dynamic link navigation example.

Uses href property of location object, string handling and parallel arrays to tailor page navigation. SOURCE

formElements.htm Displays all names & current values of an example form. Loops through all form elements. SOURCE
checkForm.htm A simple example for requiring all text boxes on a form. Only works for text boxes (type=text). SOURCE
simpleEmailCheck.htm A simple example requiring some specific email characters from a text box. A simple example of string handling on a form. SOURCE
illChars.htm Disallows certain characters from a text box on a form. The string of illegal chars is hard wired into a function. SOURCE
regExSoc.htm Uses a regular expression to determine a valid Soc. Sec Number. The regEx function is the same, with a different matching string! SOURCE
regExEmail.htm Uses a regular expression to determine a valid email address. The regEx function is the same, with a different matching string! SOURCE
checkFruit.htm Provides feedback to user about checkbox selections Advanced string handling and a checkbox element. SOURCE
checkOne.htm Validates a checkbox Radio buttons are validated in the same way. SOURCE
checkTwo.htm Validates a checkbox for at least 2 items chosen Advanced string handling and a checkbox element. SOURCE
select.htm Validates a select option Select options need only keep user from selecting "zero" option. SOURCE
selectMultiple.htm Multiple selections shown via JS Shows how to apprehend multiple selections. SOURCE
simpleform.htm Validates a textbox and a select option How to validate more than one item from a form. SOURCE
checkType.htm Loops through each for element, determines the "type" property and validates Works for "text" and "select-one" only. Leads to understanding of "checkReq". SOURCE
checkReq.htm Allows the developer to establish required and optional elements Place a letter "x" before the name of a required element. SOURCE
setFonts.htm Sets and resets the colors of all fonts on a page using the DOM Best place to start for DOM Play assignment SOURCE
2 versions of a form for writing to divs, (changeNodeValue). Compares DOM vs innerHTML method for writing to divs. innerHTML easily inserts HTML on the fly, the DOM must walk the tree to the data.
Dynamic editing of a table and it's contents via the DOM. Crawls the DOM tree, and demonstrates various DOM commands.
gallery1.htm A one page picture gallery using the DOM An example from DOM Scripting book. SOURCE
OOP JS examples. Demonstrates object oriented JavaScript.


Print this Page Back To Top

2000- <%=year(date)%> newMANIC INC, All rights reserved