TIP: Click on subject to list as thread! ANSI
echo: internet_uk
to: ALL
from: SHAUN EWING
date: 1997-12-08 19:12:00
subject: JavaScript examples I have

Hi,
 Not so long ago in one of the Internet echos, a user asked if someone
had any Javascript examples.
 Well I replied that I didn't, but gave him some places where he could
get some.
Well, I finally got some, but I cant remember his name.
 So I'm releasing this short list of some Javascript examples I have
on my Internet APC Magazine Cd-Roms
(1 month only, will release more lists when I get them, as long as
its Ok with the moderator)
If you want any of the following, netmail me at sysop@3:712/848.5 or 
shaunewing@usa.net
JavaScript Examples
------------------------------------------------------------------------------
 --
Loopexec Example
This month's column focuses on looping statements and arrays. The first 
example, loopexec, demonstrates the execution of a loop line by line. The 
example consists of three main areas: the code box on the left, the 
explanation on the right, and the variable watch on the bottom. The code box 
features the executing script, with the next line of code to be executed 
highlighted. The explanation box on the right gives a short explanation of 
the code and the program state. Below the code box is a variable watch for 
the 'counter' variable. It will alway contains the current value of counter.
------------------------------------------------------------------------------
 --
While loop example and source.
For loop example and source.
The next two examples are simple examples of looping statements. The first 
example is a while loop that prints the numbers 1 to 20 on the screen. The 
second example is the same, except that a for loop is used in place of the 
while loop. As with all of the examples, make sure that you not only look at 
the source, but click on the links to the analysis.
------------------------------------------------------------------------------
 --
Blind example and source.
This example is my tribute to Thomas Dolby, called blind.htm. If it were 
rewritten, it could conceivably be used in a Web page, but as it is, its 
primary raison d'etre is to illustrate a potential use of loops. The code 
loops through two if statements that toggle the foreground and background 
colours between black and white, while displaying text on the screen.
WARNING! This example features a rapidly flashing screen that could trigger 
an epileptic seizure. If you have epilepsy, it is not advised that you 
execute this code.
------------------------------------------------------------------------------
 --
Continue example and source.
Cont.htm is a script that illustrates the use of the continue statement. It 
is nearly identical to the for loop example, with the addition of a continue 
statement to skip printing the number 13 to the screen.
------------------------------------------------------------------------------
 --
Break example and source
This example illustrates the use of the break statement. The page is an 
interactive graffiti wall that lets you dynamically add your own graffiti. 
The code utilises the break statement to exit from an infinite loop. Check it 
out.
------------------------------------------------------------------------------
 --
Simple array example and source.
Next is a example to demonstrate how to use arrays. The scripting behind the 
example is fairly simple, but it is good to look at before moving on the next 
example. The code creates an array with four elements and assigns string 
values to each element. The script then displays the content of two of the 
variables.
------------------------------------------------------------------------------
 --
Address book example and source.
This final example illustrates a more plausible use of arrays. Although a 
fully functional program would be difficult -- not to mention impractical -- 
to implement in JavaScript, the example illustrates the use of loops and 
arrays well. The code simulates a simple address book. It asks the user how 
many entries they would like to enter, and then asks for each person's first 
name, last name and phone number. Once the user is done entering the data, 
the script displays all of the entries on the screen. 
Cya,
 Shaun Ewing
ImmortalNet Admin - shaunewing@usa.net
... (A)bort, (R)etry, or (I)nfluence with hammer.
--- FMail/Win32 1.22
---------------
* Origin: Immortal Net World HQ & Internet Distribution system (3:712/848.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.