rohitgarg83

Query Info without Map

Discussion created by rohitgarg83 on Feb 1, 2011
Latest reply on Feb 1, 2011 by hzhu
HI,
Please help me regarding below code. I want to display Query Info without Map. I copied this code from js sample code and i changed queryTask url and outFields name. But this is not working.. why? Please guide me.

Thanks
RG

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>Query Info without Map</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
    <script type="text/javascript" language="Javascript">
      dojo.require("esri.tasks.query");
      dojo.require("esri.map");

      var queryTask, query;

      function init() {
        //build query
        queryTask = new esri.tasks.QueryTask("http://localhost:8399/arcgis/rest/services/future_india/MapServer/6");
        //dojo.connect(queryTask, "onComplete", showResults);

        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = false;
  query.outFields = ["Lat", "Longs", "LocAddress"];
    
      }
   

      function execute(stateName) {
   
        query.text = stateName;        
        queryTask.execute(query,showResults);
      }

   
      function showResults(results) {
   
   alert("showResults");
   
        var s = "";
        for (var i=0, il=results.features.length; i<il; i++) {
          var featureAttributes = results.features[i].attributes;
          for (att in featureAttributes) {
            s = s + "<b>" + att + ":</b>  " + featureAttributes[att] + "<br />";
          }
        }
        dojo.byId("info").innerHTML = s;
      }
  
     dojo.addOnLoad(init);
    </script>
  </head>
  <body>
   name : <input type="text" id="stateName" value="Bhiwandi" />
    <input type="button" value="Get Details" onclick="execute(dojo.byId('stateName').value);" />
    <br />
    <br />
    <div id="info" style="padding:5px; margin:5px; background-color:#eee;">
    </div>
  </body>
</html>

Outcomes