Building a Javascript Array
by Darren HedlundMicrocyb.com
Monday, 7th November 2005
To get you started, first you have to call the scripting method you are going to use. In this case we will call javascripting method.
<script language="javascript">
Next, we call up the varible array and declare the number of entries in that varible.
test1 = new Array(5)
Now we list the entries into that varible test1 and is limited to 5.
test1[0] = "this is entry one -";
test1[1] = "this is entry two -";
test1[2] = "this is entry three -";
test1[3] = "this is entry four -";
test1[4] = "this is entry five -";
test1[1] = "this is entry two -";
test1[2] = "this is entry three -";
test1[3] = "this is entry four -";
test1[4] = "this is entry five -";
Now to display this in the document.
document.write(test1[0],test1[1],test1[2],test1[3],test1[4],test1[5]);
Now, we close the script.
</script>
Complete code:
<html>
<head>
</head>
<body>
<script language="javascript">
test1 = new Array(5)
test1[0] = "this is entry one -";
test1[1] = "this is entry two -";
test1[2] = "this is entry three -";
test1[3] = "this is entry four -";
test1[4] = "this is entry five -";
document.write(test1[0],test1[1],test1[2],test1[3],test1[4],test1[5]);
</script>
</body>
</html>
<head>
</head>
<body>
<script language="javascript">
test1 = new Array(5)
test1[0] = "this is entry one -";
test1[1] = "this is entry two -";
test1[2] = "this is entry three -";
test1[3] = "this is entry four -";
test1[4] = "this is entry five -";
document.write(test1[0],test1[1],test1[2],test1[3],test1[4],test1[5]);
</script>
</body>
</html>
Options:
Printer Friendly
Email Friend
About The Author:
Darren Hedlund is a freelance Web developer, writer, and data analyst. Darren has a graduate degree in Computer Information Science and has spent the last 15 years developing application and environments from hand held, windows, web, virtual science, gaming, artificial intelligence and graphics design. Darren's coding knowledge ranges from C+, Visual Basic, .NET, PHP, JSP, REXX, KIXX, and many others. His graphical and environmental knowledge stems in Macromedia Flash, 3D studio Max, Curious Labs Poser, Adobe Photoshop, and many others. Darren works in many platforms ranging from database, visual design, and, system development.
Darren Hedlund is a freelance Web developer, writer, and data analyst. Darren has a graduate degree in Computer Information Science and has spent the last 15 years developing application and environments from hand held, windows, web, virtual science, gaming, artificial intelligence and graphics design. Darren's coding knowledge ranges from C+, Visual Basic, .NET, PHP, JSP, REXX, KIXX, and many others. His graphical and environmental knowledge stems in Macromedia Flash, 3D studio Max, Curious Labs Poser, Adobe Photoshop, and many others. Darren works in many platforms ranging from database, visual design, and, system development.
