Programming
Images in an Arrays

Question Description

I need help with a Computer Science question. All explanations and answers will be used to help me learn.

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

Need a simple web page.

Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

Final Answer

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
*/

<html>
<head>
<title>Image Array Demo</title>
<script>

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
 counter++;
 if (counter > 3){
 counter = 0;
 } // end if
 document.imgDisplay.src = pictures[counter].src;
 document.myForm.txtDescription.value = description[counter];
} // end upDate

</script>
</head>

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

<input type = "text"
 name = "txtDescription"
 value = "blank">
<br>
<input type = "button"
 value = "next"
 onClick = "upDate()">
</form>
</center>
<hr>
</body>
</html>

Boston College

Anonymous
Top quality work from this tutor! I’ll be back!

Anonymous
Just what I needed… fantastic!

Anonymous
Use Studypool every time I am stuck with an assignment I need guidance.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4
Similar Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors