<select class="field" name="field" id="selectfield"> <option value="FIRSTNAME">First Name</option> <option value="LAST_NAME">Last Name</option> <option value="Service_ID">Service ID</option> <option value="TOWNSHIP">Township</option> </select>
var sel = dom.byId("input1").value; query.where = " (select option variable) LIKE'" + sel +"'";
Solved! Go to Solution.
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--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>Query State Info without Map</title> <script src="http://js.arcgis.com/3.8/"></script> <script> require([ "esri/tasks/query", "esri/tasks/QueryTask","dijit/registry", "dojo/dom", "dojo/on", "dojo/domReady!" ], function (Query, QueryTask,registry, dom, on) { var queryTask = new QueryTask("secure"); var query = new Query(); query.returnGeometry = false; query.outFields = [ "*" ]; on(dom.byId("execute"), "click", execute); function execute () { console.log("whooooaaaa"); var sel = dom.byId("input1").value; console.log(sel); var option= dom.byId("selectfield"); var optionValue = option.options[option.selectedIndex].value; console.log(optionValue); query.where = optionValue + "LIKE '%" + sel +"%'"; queryTask.execute(query, showResults); } function showResults (results) { var resultItems = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); } resultItems.push("<br>"); } dom.byId("info").innerHTML = resultItems.join(""); dom.byId("info1").innerHTML = resultCount; } }); </script> </head> <body> <select data-dojo-type="dijit/form/Select" class="field" name="selectfield" id="selectfield"> <option value="FIRSTNAME">First Name</option> <option value="LAST_NAME">Last Name</option> <option value="Service_ID">Service ID</option> <option value="TOWNSHIP">Township</option> </select> Total records: <span id="info1">0</span> Total records: US state name : <input type="text" id="input1" value="California"> <input id="execute" type="button" value="Get Details"> <br /> <br /> <div id="info" style="padding:5px; margin:5px; background-color:#eee;"> </div> </body> </html>
var optionValue= registry.byId("selectfield").get('value');
function execute () { var sel = dom.byId("input1").value; var optionValue= registry.byId("selectfield").get('value'); query.where =optionValue + " LIKE'%" + sel +"%'"; queryTask.execute(query, showResults); }
require([ "esri/tasks/query", "esri/tasks/QueryTask","dijit/registry", "dojo/dom", "dojo/on", "dojo/domReady!" ], function (Query, QueryTask,registry, dom, on)
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--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>Query State Info without Map</title> <script src="http://js.arcgis.com/3.8/"></script> <script> require([ "esri/tasks/query", "esri/tasks/QueryTask","dijit/registry", "dojo/dom", "dojo/on", "dojo/domReady!" ], function (Query, QueryTask,registry, dom, on) { var queryTask = new QueryTask("secure"); var query = new Query(); query.returnGeometry = false; query.outFields = [ "*" ]; on(dom.byId("execute"), "click", execute); function execute () { console.log("whooooaaaa"); var sel = dom.byId("input1").value; var optionValue = registry.byId("selectfield").item.value; query.where = optionValue + "LIKE '%" + sel +"%'"; queryTask.execute(query, showResults); } function showResults (results) { var resultItems = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); } resultItems.push("<br>"); } dom.byId("info").innerHTML = resultItems.join(""); dom.byId("info1").innerHTML = resultCount; } }); </script> </head> <body> <select class="field" name="field" id="selectfield"> <option value="FIRSTNAME">First Name</option> <option value="LAST_NAME">Last Name</option> <option value="Service_ID">Service ID</option> <option value="TOWNSHIP">Township</option> </select> Total records: <span id="info1">0</span> Total records: US state name : <input type="text" id="input1" value="California"> <input id="execute" type="button" value="Get Details"> <br /> <br /> <div id="info" style="padding:5px; margin:5px; background-color:#eee;"> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--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>Query State Info without Map</title> <script src="http://js.arcgis.com/3.8/"></script> <script> require([ "esri/tasks/query", "esri/tasks/QueryTask","dijit/registry", "dojo/dom", "dojo/on", "dojo/domReady!" ], function (Query, QueryTask,registry, dom, on) { var queryTask = new QueryTask("secure"); var query = new Query(); query.returnGeometry = false; query.outFields = [ "*" ]; on(dom.byId("execute"), "click", execute); function execute () { console.log("whooooaaaa"); var sel = dom.byId("input1").value; console.log(sel); var option= dom.byId("selectfield"); var optionValue = option.options[option.selectedIndex].value; console.log(optionValue); query.where = optionValue + "LIKE '%" + sel +"%'"; queryTask.execute(query, showResults); } function showResults (results) { var resultItems = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); } resultItems.push("<br>"); } dom.byId("info").innerHTML = resultItems.join(""); dom.byId("info1").innerHTML = resultCount; } }); </script> </head> <body> <select data-dojo-type="dijit/form/Select" class="field" name="selectfield" id="selectfield"> <option value="FIRSTNAME">First Name</option> <option value="LAST_NAME">Last Name</option> <option value="Service_ID">Service ID</option> <option value="TOWNSHIP">Township</option> </select> Total records: <span id="info1">0</span> Total records: US state name : <input type="text" id="input1" value="California"> <input id="execute" type="button" value="Get Details"> <br /> <br /> <div id="info" style="padding:5px; margin:5px; background-color:#eee;"> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css"> <!--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>Query State Info without Map</title> <script src="http://js.arcgis.com/3.9/"></script> <script> require([ "esri/tasks/query", "esri/tasks/QueryTask","dijit/registry", "dojo/dom", "dojo/on", "dojo/parser","dojo/domReady!" ], function (Query, QueryTask,registry, dom, on, parser) { parser.parse(); var queryTask = new QueryTask("secure"); var query = new Query(); query.returnGeometry = false; query.outFields = [ "*" ]; on(dom.byId("execute"), "click", execute); function execute () { console.log("whooooaaaa"); var sel = dom.byId("input1").value; console.log(sel); var optionValue= registry.byId("selectfield"); console.log(optionValue); query.where = optionValue + "LIKE '%" + sel +"%'"; queryTask.execute(query, showResults); } function showResults (results) { var resultItems = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); } resultItems.push("<br>"); } dom.byId("info").innerHTML = resultItems.join(""); dom.byId("info1").innerHTML = resultCount; } }); </script> </head> <body> <select data-dojo-type="dijit/form/Select" class="field" name="selectfield" id="selectfield"> <option value="FIRSTNAME">First Name</option> <option value="LAST_NAME">Last Name</option> <option value="Service_ID">Service ID</option> <option value="TOWNSHIP">Township</option> </select> Total records: <span id="info1">0</span> Total records: US state name : <input type="text" id="input1" value="California"> <input id="execute" type="button" value="Get Details"> <br /> <br /> <div id="info" style="padding:5px; margin:5px; background-color:#eee;"> </div> </body> </html>