Images in an Arrays

Computer Science
Tutor: None Selected Time limit: 1 Day

How to store imagesĀ in an array? using Java Script?

Need a simple web page.

May 14th, 2014

you can store images in array using java script below:


JavaScript Programming for the Absolute Beginner
by Andy Harris

Publisher: Muska & Lipman/Premier-Trade

Language: English
ISBN: 0761534105

<title>Image Array Demo</title>

var description = new Array("blank", "triangle", "circle", "square");
var pictures = new Array(3);
var counter = 0;

function initialize(){
 // sets up the array with some startin values
 // Andy Harris
 pictures[0] = new Image(50, 50);
 pictures[0].src = "blank.gif";
 pictures[1] = new Image(50, 50);
 pictures[1].src = "triangle.gif";
 pictures[2] = new Image(50, 50);
 pictures[2].src = "circle.gif";
 pictures[3] = new Image(50, 50);
 pictures[3].src = "square.gif";

} // end initialize 

function upDate(){
 //increments the counter and shows the next description
 if (counter > 3){
 counter = 0;
 } // end if
 document.imgDisplay.src = pictures[counter].src;
 document.myForm.txtDescription.value = description[counter];
} // end upDate


<body onLoad = "initialize()">
<h1>Image Array Demo<hr></h1>
<form name = "myForm">
<img src = "blank.gif"
 name = "imgDisplay"
 height = 100
 width = 100>

<input type = "text"
 name = "txtDescription"
 value = "blank">
<input type = "button"
 value = "next"
 onClick = "upDate()">

May 14th, 2014

Are you studying on the go? Check out our FREE app and post questions on the fly!
Download on the
App Store
May 14th, 2014
May 14th, 2014
Dec 11th, 2016
Mark as Final Answer
Unmark as Final Answer
Final Answer

Secure Information

Content will be erased after question is completed.

Final Answer