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
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with for loop in javascript

    Hi,

    I am developing the google application. In my google.js file consists the
    Code:
            icon1=new GIcon();
    	icon1.image = "images/bmw-small.png";
    	icon1.shadow = "images/shadow50.png";
    	icon1.iconSize = new GSize(25, 25);
    	icon1.shadowSize = new GSize(20, 19);
    	icon1.iconAnchor = new GPoint(10, 15);
    	icon1.infoWindowAnchor = new GPoint(9, 2);
    	icon1.infoShadowAnchor = new GPoint(18, 25);
    	icon2 = new GIcon();
    	icon2.image = "images/bmw-small.png";
    	icon2.shadow = "images/shadow50.png";
    	icon2.iconSize = new GSize(25, 25);
    	icon2.shadowSize = new GSize(20, 19);
    	icon2.iconAnchor = new GPoint(15, 20);
    	icon2.infoWindowAnchor = new GPoint(9, 2);
    	icon2.infoShadowAnchor = new GPoint(18, 25);
    	icon3 = new GIcon();
    	icon3.image = "images/bmw-small.png";
    	icon3.shadow = "images/shadow50.png";
    	icon3.iconSize = new GSize(25, 25);
    	icon3.shadowSize = new GSize(20, 19);
    	icon3.iconAnchor = new GPoint(20, 25);
    	icon3.infoWindowAnchor = new GPoint(9, 2);
    	icon3.infoShadowAnchor = new GPoint(18, 25);
    	icon4 = new GIcon();
    	icon4.image = "images/bmw-small.png";
    	icon4.shadow = "images/shadow50.png";
    	icon4.iconSize = new GSize(25, 25);
    	icon4.shadowSize = new GSize(20, 19);
    	icon4.iconAnchor = new GPoint(25, 30);
    	icon4.infoWindowAnchor = new GPoint(9, 2);
    	icon4.infoShadowAnchor = new GPoint(18, 25);
    	icon5 = new GIcon();
    	icon5.image = "images/bmw-small.png";
    	icon5.shadow = "images/shadow50.png";
    	icon5.iconSize = new GSize(25, 25);
    	icon5.shadowSize = new GSize(20, 19);
    	icon5.iconAnchor = new GPoint(30, 35);
    	icon5.infoWindowAnchor = new GPoint(9, 2);
    	icon5.infoShadowAnchor = new GPoint(18, 25);
    Now i want to replace this with for llo condition .For that purpose i have changed that as
    Code:
    for(var i=1;i<=5;i++){
    icon5 = new GIcon();
    	'icon'+i.image = "images/bmw-small.png";
    	'icon'+i.shadow = "images/shadow50.png";
    	'icon'+i.iconSize = new GSize(25, 25);
    	'icon'+i.shadowSize = new GSize(20, 19);
    	'icon'+i.iconAnchor = new GPoint(30, 35);
    	'icon'+i.infoWindowAnchor = new GPoint(9, 2);
    	'icon'+i.infoShadowAnchor = new GPoint(18, 25);
    }
    But this for llop condition is not working. Please anybody tell the whats the problem in my code and how can use to work the for loop condition.Please help me Its very urgent.



    Thanks
    Swetha

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    301
    Thanks
    2
    Thanked 30 Times in 30 Posts
    Because you're always assigning stuff to "icon5"?


  •  

    Posting Permissions

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