QueryTask with 2 user inputs Javascript API

Discussion created by da_arcgis on Aug 19, 2010
Latest reply on Aug 20, 2010 by doncav
Hi All

I'm new to ESRI and Javascript and i'm a little stuck.

How do I get a queryTask to run with 2 user inputs?

I'm looking at having 2 textboxes and one onclick button, but I want both user inputs to be used in the same query.

Here is my code with one input, I think that the code that I have bolded need to be altered but I can't seem to get it to work.

                //build query task
        queryTask = new esri.tasks.QueryTask("http://arcgis/ArcGIS/rest/services/AllIncidents/MapServer/0");

        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = true;
        query.outFields = ["ADDRESS1", "ADDRESS2", "STATIONGROUND"];

        //create the infoTemplate to be used in an InfoWindow.
        //All ${attributeName} will be substituted with the attribute value for current feature.
        infoTemplate = new esri.InfoTemplate("${ADDRESS1}", "Address1 : ${ADDRESS1}<br/> Address2 : ${ADDRESS2}<br />station : ${STATIONGROUND}");

  //create symbol for selected features
  symbol = new esri.symbol.SimpleMarkerSymbol();
  symbol.setColor(new dojo.Color([0,255,0,0.25]));


   function executeQueryTask(station) {
        //set query based on what user typed in for population;

   query.where = "Upper(ADDRESS1) LIKE '"+ "%" + station.toUpperCase() + "%" +  "'" ;

  //execute query and call showResults on completion

function showResults(featureSet) {
        //remove all graphics on the maps graphics layer

        //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the map.

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

        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];

          //Set the infoTemplate.

          //Add graphic to the map graphics layer.

  <body class="tundra">
Please Enter Incident Address: <input type="text" id="station" value="a164 rd" />

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

<div id="mapDiv" style="width:600px; height:600px; border:1px solid #000;"></div>
Click on a city once it's highlighted to get an InfoWindow.