Jump to content

[SOLVED] debug question about for loop


rndilger

Recommended Posts

Hello, I'm trying to figure out why the following code doesn't work, and I will admit that I'm green when it comes to JS so please bear with me.

 

var chooseIcon = ["a","b","c","d","e,"f","g","h","i"];
var k = 1;
for (k=1; k<=chooseIcon.length; k++) {
	var icon+ k + = new GIcon();
	icon+ k +.image = "images/mapmarker"+ k +".gif";
	icon+ k +.iconSize = new GSize(12, 12);
	icon+ k +.iconAnchor = new GPoint(0, 0);
	icon+ k +.infoWindowAnchor = new GPoint(5, 0);
}

 

All I want this code to do is to automate the writing of the following...

 

var icon1 = new GIcon();

icon1.image = "images/mapmarker1.gif";

icon1.iconSize = new GSize(12, 12);

icon1.iconAnchor = new GPoint(0, 0);

icon1.infoWindowAnchor = new GPoint(5, 0);

 

same thing with 2, 3, etc...

 

I assume it's a simple fix, but I'm stumped at the moment.

 

As always, thanks!

 

Ryan

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.