bebeo05

Problem Find task

Discussion created by bebeo05 on Jun 21, 2012
Latest reply on Aug 16, 2012 by maxwellr
Im Problem findtask need help:
do not show results it is empty
DataMAp: http://www.mediafire.com/download.php?qyg3b97pzpngcqb


Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Simple Find</title>
    <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/1.6/arcgis/js/dojo/dijit/themes/claro/claro.css">
    <script type="text/javascript" src="http://localhost/arcgis_js_api/library/1.6/arcgis/"></script>
    <script type="text/javascript">
      dojo.require("esri.map");
      dojo.require("esri.tasks.find");

      var find, params;
      function init() {
        find = new esri.tasks.FindTask("http://localhost/ArcGIS/rest/services/gisDuLich/DuLich/MapServer");
        params = new esri.tasks.FindParameters();
        params.contains=true;
        params.returnGeometry=true;
        params.layerIds = [0,1,2,3,4,5,6,7,8];
     
        params.searchFields = ['maDoiTuong','danhTuChung','diaDanh','diaChi','doiTuong','maNhanDang','ngayThuNhan','ngayCapNhat','maDoiTuong','maDonViHanhChinh','danhTuChung','diaDanh','dienTich','nhandang','ten'];
      }

      function doFind() {
        params.searchText = dojo.byId("searchText1").value;
        find.execute(params, showResults);
      }

      function showResults(results) {
      alert("Don't shows results "+results);
        var result, attribs;
        var s = ["<table border=\"1\"><thead><tr style=\"background-color:#ccc;\"><td>OBJECTID</td><td>Dia Danh</td></tr></thead><tbody id=\"states\">"];
        dojo.forEach(results,function(result){
          attribs = result.feature.attributes;
          alert(result.feature.attributes);
          for (j in result.feature.attributes) {
          alert(j);
            if (j.toUpperCase() != "OBJECTID" && j.toUpperCase() != "SHAPE")
                if (result.feature.attributes[j].toUpperCase() != "NULL")               
                s.push("<tr><td>" + j + "</td><td>" + result.feature.attributes[j]+ "</td></tr>");
        }
          
        });
        s.push("</tbody></table>");
        dojo.byId("tbl").innerHTML = s.join("");
      }

      dojo.addOnLoad(init);
    </script>

  </head>
  <body class="claro">
    Dia Danh: <input type="text" id="searchText1" size="40" value="Trường" />
    <input type="button" value="Find" onclick="doFind()" />

    <div id="tbl"></div>

  </body>
</html>

Outcomes