Rickey,
So here is your other threads example code with the feature count added to the end of the buttons div:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<!--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>Feature Layer - display results as an InfoWindow onHover</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.6/js/dojo/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css">
<style>
html, body, #mapDiv {
padding:0;
margin:0;
height:100%;
}
#mapDiv {
position: relative;
}
#buttons {
background: #fff;
box-shadow: 0 0 5px #888;
left: 1em;
padding: 0.5em;
position: absolute;
top: 1em;
z-index: 40;
}
</style>
<script src="http://js.arcgis.com/3.6/"></script>
<script>
var map, dialog;
require([
"esri/map", "esri/layers/FeatureLayer",
"esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol",
"esri/renderers/SimpleRenderer", "dojo/query", "dojo/on", "dojo/dom"
], function(
Map, FeatureLayer,
SimpleFillSymbol, SimpleLineSymbol,
SimpleRenderer, query, on, dom
) {
map = new Map("mapDiv", {
basemap: "streets",
center: [-80.94, 33.646],
zoom: 6,
slider: false
});
var states = new FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5", {
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: ["NAME", "POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI", "AVE_FAM_SZ","SQMI","SUB_REGION", "STATE_NAME"]
});
states.setDefinitionExpression("STATE_NAME = 'South Carolina'");
var symbol = new SimpleFillSymbol();
states.setRenderer(new SimpleRenderer(symbol));
map.addLayer(states);
states.on("update-end", function(evt){
console.info(evt);
dom.byId("featcount").innerHTML = " " + evt.target.graphics.length;
});
//setup click event for buttons
query("input").forEach(function(node){
on(node, "click", function (e) {
var defExp = states.getDefinitionExpression(),
defExp2 = "",
defExp3 = "";
switch (e.srcElement.value) {
case "East Coast":
defExp = "SUB_REGION LIKE '% Atlantic' AND STATE_NAME IN( 'New York', 'New Jersey', 'Delaware')";
break;
case "East North Central":
defExp = "SUB_REGION='East North Central'";
break;
case "Pacific":
defExp ="SUB_REGION='Pacific'";
break;
case "Clear":
defExp = "";
break;
case "SQMI":
defExp2 = "SQMI>20000";
break;
case "AVE_FAM_SZ":
defExp2 = "AVE_FAM_SZ<3";
break;
case "PopMil":
defExp2 = "POP2007>1000000";
break;
case "All":
defExp3 = "1=1";
break;
}
//var fDefExpr = (defExp !== "") ? ((defExp2 !== "") ? defExp + " AND " + defExp2 : defExp) : ((defExp2 !== "") ? defExp2 : "");
defArr = [];
if(defExp !== ""){
defArr.push(defExp);
}
if(defExp2 !== ""){
defArr.push(defExp2);
}
if(defExp3 !== ""){
defArr.push(defExp3);
}
states.setDefinitionExpression(defArr.join(" AND "));
});
});
});
</script>
</head>
<body class="tundra">
<div id="mapDiv">
<div id="buttons">
<input type="button" value="East Coast"/>
<input type="button" value = "East North Central"/>
<input type="button" value = "Pacific"/>
<input type="button" value="SQMI"/>
<input type="button" value="AVE_FAM_SZ"/>
<input type="button" value="PopMil"/>
<input type="button" value="Clear"/>
<span id="featcount"> ???</span>
</div>
</div>
</body>
</html>