Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    147
    Thanks
    31
    Thanked 2 Times in 2 Posts

    for loop array wont alert?

    Hi

    Thanks for the help.

    if I put alert(Images[i]); in the for loop then it alerts all images 1 to 6

    but if I put alert](Images3); out site it ignores the alert?

    Why..... surly all these images1 to 6 should be there?

    Thanks

    for the help

    A




    Code:
    for(var i=1;i<=6;i++){
    		
    		var Images = new Array()
    
    		Images[i] = "images/no"+i+".jpg";
    				
    	}
    
    		alert(Images3);

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    alert(Images3); is being ignored because the variable Images3 is not defined. You probably mean Images[3].

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    147
    Thanks
    31
    Thanked 2 Times in 2 Posts
    Hi Thanks for the reply


    i added Images[3]

    now it says images3 undefined?

    Any ideas of how to define it?

    thanks for the help

  • #4
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Why would it say images3 is undefined? Unless you're holding out on me, images3 isn't even mentioned in your code. There has been Images3, but you just changed that to Images[3], right?

    Post some code or I'm afraid I won't be able to help you.

  • #5
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Sounds like you are cached if you make a change and you re not seeing it. Clear it.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #6
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Code:
    for(var i=1;i<=6;i++){
    		
    		var Images = new Array()
    
    		Images[i] = "images/no"+i+".jpg";
    				
    	}
    
    		alert(Images3);
    Every time your looping your clearing the array it shoudl be
    Code:
    var Images = [] // new array is only to defind max entryed E.G "new Array(100);" [] set a no limit array
    for(var i = 1; i <= 6 ; i++){
    		Images[i] = "images/no"+i+".jpg";
    	}
    
    		alert(Images[3]);
    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)

  • Users who have thanked barkermn01 for this post:

    andrew1234 (07-18-2009)

  • #7
    Regular Coder
    Join Date
    Oct 2002
    Posts
    147
    Thanks
    31
    Thanked 2 Times in 2 Posts
    thanks for the help

    that makes so much sense.....

  • #8
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    I Would, like to say that why has a Senior Coder, not noticed this???

    But i dont want to flame or start a flame but people should read code porperly befor answering
    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,507 Times in 2,485 Posts
    There are none so blind as those that cannot see.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •