Setting map extent to a group of graphics

Discussion created by samirgambhir on Feb 22, 2011
Latest reply on Mar 11, 2011 by jjmiller1980
I am running a query to select a number of polygons based on an intersecting polygon. The selected polygons are contiguous and are highlighted when the query is complete. I am trying to set the map extent to the extent of all these polygons combined together but have been unsuccessful. I have tried suggestions posted on these forums and using samples provided by ESRI but am still unable to get the map to zoom to this area. I have tried creating an array to push graphics inside it. I have also tried creating a polygon feature, a feature set and a graphicsLayer as a container to hold all the selected graphics, but it didn't work. I am using ArcGIS Server 9.3 with JavaScript API. Please help.
(Note: The code below has been extracted from a longer version. It might be missing some braces)

function findPolygonsInExtent(extent) {
  var graphics =;     
  var attr =[];
  var items = [];
        var graphic;
  var len=0;
  for (var i=0, il=graphics.length; i<il; i++) {
          graphic = graphics[i];
          if (extent.intersects(graphic.geometry)) {
   len = len + 1;
   var results = [];
   var featureAttributes = graphic.attributes;
   for (att in featureAttributes) {
             var s = featureAttributes[att];
   attr = results.slice(0,10);
   for(var j=0, jl=10; j<jl; j++)
    } //if
          else if (graphic.symbol == highlightSymbol) {
        } //for
  map.setExtent(//some polygon feature//.geometry.getExtent());