Hi. I need some help with arrays in JavaScript. I am creating a slideshow and have to store the images in an array on a separate file. I need some feedback as far as am I missing something in this file and how can I then call this array into my slideshow file? So far, I have:

<script type="text/javascript">

	// Create an array to hold image filenames
	var images = new Array();
 
	// Populate array with image filenames
	imgname[0] = 'home.jpg';
	imgname[1] = 'beach.jpg';
	imgname[2] = 'pool.jpg';
	imgname[3] = 'garden.jpg';
	imgname[4] = 'pond.jpg';
	imgname[5] = 'car.jpg';

</script>

You create a new array

var images = new Array();

and then you want to reference

imgname[0] = 'home.jpg';
...

..hmmm! names do not match.

Also, creating a new array, does not create a new array if images... you may want to create the elements of the array as:

images[0] = new image();
image[0].src = 'home.jpg';

...

Thanks! I'll try that.

> images[0] = new image(); images[0] = new Image();

Oops!
Sorry for the typo.
Thank YOU ~s.o.s~

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.