Written Origninally for Netscape 2.02, Win95
Although the array construction is old style, this page still works. See notes in the script text about changes for JS1.1 and 1.2
Making an array of strings
Declare the array, globally if necessary
Make the array with a user defined function
Enter the value for each array element
Retrieve information as follows:
Size of array = strArray.length
Any string = strArray[index]
Length of any string = strArray[index].length
This function presents an alert box with the strings and their lengths. Strings are made on page load with
setUpArray()
which calls
strArray = new makeArray(10,'')
and then initializes each of the strings of the array
strArray[1] = 'enter strings here;etc'
Notes:
See script for makeArray function
strArray should be global and declared out side of any function with "var strArray"
function showStringsInAlert()
{
var astr = ''
for (var ii = 1 ; ii<=10 ; ii++)
{
astr += strArray[ii] + ' -- '
astr += 'length = ' + strArray[ii].length
astr += '\n'
}
alert(astr)
}
Showing an Array of Pictures from Their Names
This function writes an on-the-fly window and uses the strings in the array to retrieve and display gifs.
Script
This page has been accessed
times since March 8, 1999.