Variables between functions

Discussion created by mborr on Dec 1, 2011
Latest reply on Dec 5, 2011 by mborr
Hi, this may be stupidly easy, but I cannot pass a variable (geom) to another function. I defined geom globally, and it will display when I call the "innerHTML" within its own function, but when I put it in function gpit, it comes back undefined. I need to use geom to do other things within gpit, but can't seem to see it. Any ideas why I cannot do this?

var geom;

  function showResults(candidates, result) {
        var candidate;
        var symbol = new esri.symbol.SimpleMarkerSymbol();
        var infoTemplate = new esri.InfoTemplate("Location","Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}");

        symbol.setColor(new dojo.Color([153,0,51,0.75]));

        dojo.every(candidates,function(candidate, geom){
          if (candidate.score > 80) {
            var attributes = { address: candidate.address, score:candidate.score, locatorName:candidate.attributes.Loc_name };  
            var geom = candidate.location;
            var graphic = new esri.Graphic(geom, symbol, attributes, infoTemplate);
            //add a graphic to the map at the geocoded location
            //add a text symbol to the map listing the location of the matched address.
            var displayText = candidate.address;
            var font = new esri.symbol.Font("16pt",esri.symbol.Font.STYLE_NORMAL, esri.symbol.Font.VARIANT_NORMAL,esri.symbol.Font.WEIGHT_BOLD,"Helvetica");
            var textSymbol = new esri.symbol.TextSymbol(displayText,font,new dojo.Color("#666633"));
            map.graphics.add(new esri.Graphic(geom, textSymbol));
            return false; //break out of loop after one candidate with score greater  than 80 is found.
        if(geom !== undefined){
     function gpit(geom){
   dojo.byId("a").innerHTML = geom.x;