| | |
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 ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column createrange() css cursor decimal dependent design disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl listbox math media microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php player post problem progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






