All,<br><br>I'm working with the boxes example included as part of the OpenLayers distribution, and am having some problems extending it. Basically, I want to create list of boxes, and allow users to click on those and be redirected to another location, specified in the "box_extents" array. I'm able to mostly do this by registering an event for the boxes, but herein lies the difficulty. The destination url for individual boxes (taken from box_extents) is always that of the last element in the box_extents array. As each box should direct to its array-given url, this is a big problem. Any insight or advice you how to make each box access its correct array parameters through that function would be greatly appreciated. THe code I'm using is below.<br><br><br> var boxes = new OpenLayers.Layer.Boxes( "Boxes" );<br><br> var box_extents =
[<br> [-92.559, 42.889, -82.146, 43.126,'http://yahoo.com?','blue'],<br> [-89.559, 40.889, -88.146, 41.126,'http://google.com?','blue2']<br> ];<br><br> var names = new Array("blue","blue2","red","red2","green","green2");<br><br> for (var i = 0; i < box_extents.length; i++) {<br> ext = box_extents[i];<br> bounds = new OpenLayers.Bounds(ext[0], ext[1], ext[2], ext[3]);<br> box = new
OpenLayers.Marker.Box(bounds);<br> box.setBorder("red",2);<br> box.div.id = names[i];<br> //alert(box.div.id);<br> //this gets assigned correctly<br><br> box.events.register("click", box, function (e) {<br> this.setBorder("yellow",2);<br>
//alert(box.div.id);<br> //after click event, always the last element in the array (blue2)<br> //and subsequently, the wrong url for but the last array element<br> window.location.href=ext[4];<br> //wrong redirect :(<br> });<br> boxes.addMarker(box);<br>
}<br><br>map.addLayer(boxes);<br><p> 
<hr size=1>Get easy, one-click access to your favorites.
<a href="http://us.rd.yahoo.com/evt=51443/*http://www.yahoo.com/r/hs"> Make Yahoo! your homepage.</a>