| | |
Using an array in Javascript
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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
and then you want to reference
..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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
var images = new Array();
and then you want to reference
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
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.
Henry.
Before printing this message, make sure is necessary.
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How do I identify what type and where my code is in the HTML DOM tree?
- Next Thread: AJAX DIV Refresh Help....
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser bug captchaformproblem cart checkbox child class close codes createrange() css cursor date debugger decimal dependent design disablefirebug dom dropdown editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming progressbar prototype redirect runtime safari scale scriptlets scroll search security shopping size software toggle unicode w3c web wysiwyg \n






