Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to use the Find Task to search for records in a map service, then display the results in an HTML table.

Although FindTask does not require you to display a map, its constructor requires a URL to an ArcGIS Server map service. FindParameters restricts the search to only the STATE_NAME and STATE_FIPS fields of the States layer (index 2).

params = new FindParameters();
params.layerIds = [2];
params.searchFields: ["NAME"];

When you click the Find button, the function doFind reads the input box and uses it as the search text. The find is then executed:

params.searchText = dojo.byId("searchText").value;
find.execute(params, showResults);

The results are returned as an array of FindResult objects. These are graphics, which have attributes that you can retrieve through syntax such as result.feature.attributes.STATE_NAME. After the find task completes, the callback function showResults() loops through these features and constructs an HTML table from their attributes.

Sample search results


There were no match results from your search criteria.