...

View Full Version : Problem with for loop in javascript



swethak
07-16-2009, 06:38 AM
Hi,

I am developing the google application. In my google.js file consists the


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


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

fside
07-16-2009, 06:53 AM
Because you're always assigning stuff to "icon5"?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum