tfman716

Cant get the execute query task to run

Discussion created by tfman716 on May 28, 2014
Latest reply on May 28, 2014 by manish_patel
I want to have a map load as soon as the page is open...it will plot all 1000+ points on the map...then at the top of the page there is a text box where the user can filter the map. Once the button is clicked it should kick off a query task and query the layer only showing those that were typed in the text box. I keep getting the error executeQueryTask is not defined...I know I am missing something simple but cant figure it out. My code is below:

function init() {
  
  queryTask = new esri.tasks.QueryTask("https://myserver/Locations/MapServer/0");

        //initialize query
        query = new Query();
        query.returnGeometry = true;
        query.outFields = ["*"];
  }
  function executeQueryTask() {
    //set query based on what user typed in for population;
    query.where = "QUALIFICAT IN " + QUALIFICAT;

    //execute query
    queryTask.execute(query,showResults);
  }
   function showResults(featureSet) {
    //remove all graphics on the maps graphics layer
    map.graphics.clear();

    //Performance enhancer - assign featureSet array to a single variable.
    var resultFeatures = featureSet.features;

    //Loop through each feature returned
    for (var i=0, il=resultFeatures.length; i<il; i++) {
      //Get the current feature from the featureSet.
      //Feature is a graphic
      var graphic = resultFeatures[i];
      graphic.setSymbol(symbol);

      //Set the infoTemplate.
      graphic.setInfoTemplate(infoTemplate);

      //Add graphic to the map graphics layer.
      map.graphics.add(graphic);
    }
  } 
<body>
    <br/>
    Qualification Type: <input type="text" id="QUALIFICAT" value="OT" />
    <input type="button" value="Get Details" onclick="executeQueryTask(dojo.byId('QUALIFICAT').value);" />
  <div id="map"></div>
  <div id="footer"
  data-dojo-TYPE="dijit.layout.ContentPane"
  data-dojo-props="region:'bottom'">
 
  </div>

Outcomes