Cant get the execute query task to run

897
3
05-28-2014 12:04 PM
DaveTaylor
New Contributor
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;
      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>
0 Kudos
3 Replies
JeffPace
MVP Alum
you are calling executeQueryTask(variable)

but you have no function executeQueryTask(variable), you only have executeQueryTask() which takes no arguments
0 Kudos
DaveTaylor
New Contributor
Sorry I am not following.

I must be overlooking something...
0 Kudos
ManishkumarPatel
Occasional Contributor II
Hi Dave,

The function you are trying to call takes one parameter

<input type="button" value="Get Details" onclick="executeQueryTask(dojo.byId('QUALIFICAT').value);" />


But the function you have in the code snippet does not take any parameter
function executeQueryTask() {
    //set query based on what user typed in for population;
    query.where = "QUALIFICAT IN " + QUALIFICAT;

    //execute query
    queryTask.execute(query,showResults);
  }


Instead try to change to below:
function executeQueryTask(QUALIFICAT) {
    //set query based on what user typed in for population;
    query.where = "QUALIFICAT IN " + QUALIFICAT;

    //execute query
    queryTask.execute(query,showResults);
  }


Hope this helps.

Regards,
Manish
0 Kudos