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 2 of 2

Thread: array and loop

  1. #1
    Regular Coder
    Join Date
    Dec 2007
    Posts
    269
    Thanks
    28
    Thanked 0 Times in 0 Posts

    array and loop

    how can i make following shorter (as a loop)

    Code:
    fadeimages[0]=["mkportal/images/0.jpg", "http://www.google.com/images/0.jpg", "_new"]
    fadeimages[1]=["mkportal/images/1.jpg", "http://www.google.com/images/1.jpg", "_new"]
    fadeimages[2]=["mkportal/images/2.jpg", "http://www.google.com/images/2.jpg", "_new"]
    fadeimages[3]=["mkportal/images/3.jpg", "http://www.google.com/images/3.jpg", "_new"]
    fadeimages[4]=["mkportal/images/4.jpg", "http://www.google.com/images/4.jpg", "_new"]
    fadeimages[5]=["mkportal/images/5.jpg", "http://www.google.com/images/5.jpg", "_new"]
    fadeimages[6]=["mkportal/images/6.jpg", "http://www.google.com/images/6.jpg", "_new"]
    fadeimages[7]=["mkportal/images/7.jpg", "http://www.google.com/images/7.jpg", "_new"]
    fadeimages[8]=["mkportal/images/8.jpg", "http://www.google.com/images/8.jpg", "_new"]
    fadeimages[9]=["mkportal/images/9.jpg", "http://www.google.com/images/9.jpg", "_new"]

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    728
    Thanks
    35
    Thanked 132 Times in 123 Posts
    Code:
    var fadeimages= [],i= 0;
    while(i<10){
    	fadeimages[i]= [
    		'mkportal/images/'+i+'.jpg',
    		'http://www.google.com/images/'+i+'.jpg',
    		'_new'
    	]
    	i+=1;
    }


  •  

    Posting Permissions

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