[Contents]

jsEditor - Using the Array Wizard

Aim: to demonstrate how to use the array wizard

From the main menu choose Wizards, Array Wizard.

Copy the following and paste them into the left box of the Wizard:

jsalerts.htm

jsalertslink.htm

jsblocks.htm

jsContents.htm

Change the default name to myFiles. The following code results:

myFiles=new Array(4);

myFiles[0]="jsalerts.htm";

myFiles[1]="jsalertslink.htm";

myFiles[2]="jsblocks.htm";

myFiles[3]="jsContents.htm";

So, you have got an array in just a few seconds (or minutes) if I hadn't copied the files for you!

Now copy the following into the Wizard's left-hand box. (Click clear to remove the previous list) and change the array name to myTitles:

jsEditor Tutorial: boilerplate code - alerts

jsEditor Tutorial: boilerplate code - alert's link

Boilerplate: blocks

Contents jsEditor Tutorial

The following code results:

myTitles=new Array(4);

myTitles[0]="jsEditor Tutorial: boilerplate code - alerts";

myTitles[1]="jsEditor Tutorial: boilerplate code - alert's link";

myTitles[2]="Boilerplate: blocks";

myTitles[3]="Contents jsEditor Tutorial";

Once again you have created an array in a few seconds.

Add the following code:

answer=prompt("Enter a number between zero and 3","2");

if (answer>-1 && answer<4&&answer!=null&&answer!=""){

alert("The number \""+answer+"\" refers to file \""+myFiles[answer]+"\" which has the title: \n\""+

myTitles[answer]+"\"");

}

else

alert("You did not enter a number in the required range")

Select all the code and add JavaScript tags. Run the code by pressing F9.

 

You have learned how to: