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 391,809 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,509 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: 1132 | Replies: 5
Join Date: Oct 2006
Posts: 7
Reputation: {-_-} is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
{-_-} {-_-} is offline Offline
Newbie Poster

Getting funky errors with a simple for loop, anyone care to help?

  #1  
Nov 29th, 2006
Hello All,


I have a javascript image preloading script I'm writing, and it basically creates an array called "array_name" which contains the image filenames, and then uses a for loop to assign "array_name"'s elements to another array called "preload". I know my syntax is good, but the firefox javascript inspector is complaining each time I attempt to run this. Can anyone take a look at the code, and tell me what I'm doing wrong?



Thank You



  1. function imgLoad() {
  2. array_name=[];
  3. preload=[];
  4. array_name[0]='images/bgcolor.gif';
  5. array_name[1]='images/blackdot.gif';
  6. array_name[2]='images/bold.gif';
  7. array_name[3]='images/centre.gif';
  8. array_name[4]='images/copy.gif';
  9. array_name[5]='images/cut.gif';
  10. array_name[6]='images/email.gif';
  11. array_name[7]='images/hr.gif';
  12. array_name[8]='images/hyperlink.gif';
  13. array_name[9]='images/image.gif';
  14. array_name[10]='images/indent.gif';
  15. array_name[11]='images/insert_table.gif';
  16. array_name[12]='images/italic.gif';
  17. array_name[13]='images/justifyfull.gif';
  18. array_name[14]='images/left_just.gif';
  19. array_name[15]='images/list.gif';
  20. array_name[16]='images/numbered_list.gif';
  21. array_name[17]='images/outdent.gif';
  22. array_name[18]='images/paste.gif';
  23. array_name[19]='images/redo.gif';
  24. array_name[20]='images/right_just.gif';
  25. array_name[21]='images/smiley.gif';
  26. array_name[22]='images/spellcheck.gif';
  27. array_name[23]='images/textcolor.gif';
  28. array_name[24]='images/underline.gif';
  29. array_name[25]='images/undo.gif';
  30. for (var i = 0; i < array_name.length; i++) {
  31. var preload[i] = new Image();
  32. preload[i].src = array_name[i];
  33. }
  34. }
AddThis Social Bookmark Button
Reply With Quote  

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

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

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