User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,579 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,410 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 849 | Replies: 4
Reply
Join Date: Nov 2007
Posts: 8
Reputation: Gia is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Gia's Avatar
Gia Gia is offline Offline
Newbie Poster

Using an array in Javascript

  #1  
Apr 12th, 2008
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>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2008
Location: Madrid - Spain
Posts: 20
Reputation: HenryGR is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
HenryGR's Avatar
HenryGR HenryGR is offline Offline
Newbie Poster

Re: Using an array in Javascript

  #2  
Apr 13th, 2008
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';

...
You keep going, have a Nice day!
Henry.

Before printing this message, make sure is necessary.
Reply With Quote  
Join Date: Nov 2007
Posts: 8
Reputation: Gia is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Gia's Avatar
Gia Gia is offline Offline
Newbie Poster

Re: Using an array in Javascript

  #3  
Apr 13th, 2008
Thanks! I'll try that.
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,851
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Using an array in Javascript

  #4  
Apr 15th, 2008
> images[0] = new image();

images[0] = new Image();
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Mar 2008
Location: Madrid - Spain
Posts: 20
Reputation: HenryGR is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
HenryGR's Avatar
HenryGR HenryGR is offline Offline
Newbie Poster

Re: Using an array in Javascript

  #5  
Apr 15th, 2008
Oops!
Sorry for the typo.
Thank YOU ~s.o.s~
You keep going, have a Nice day!
Henry.

Before printing this message, make sure is necessary.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:28 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC