Hi all, I made a dropdown that queries some attributes by "county" and returns results in a dropdown. Now I need to enable the user to select values onchange or current from this prepoulated dropdown. I was able to get the first value but not the other values. Any ideas?
variable that stores the select value
var pickerValues;
Queries for drop down:
//Select values from Alameda only - onload var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/ResourceMgmt/WatershedMapper10_2/MapServer/5"); var query = new Query(); query.returnGeometry = false; query.outFields = ["CALWNUM"]; query.where = "County = 'Alameda'"; queryTask.execute(query, function (results) { //parse results and add to autocomplete widget $.each(results.features, function (index, value) { $('#selectpickerValues').append($('<option>', { value: value, text: value.attributes.CALWNUM })); }); }); //Query Planning Watershed $("#selectpickerCounty").change(function () { $('#selectpickerValues').empty(); var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/ResourceMgmt/WatershedMapper10_2/MapServer/5"); var query = new Query(); query.returnGeometry = false; query.outFields = ["CALWNUM"]; query.where = "County='" + pickerCounty + "'"; queryTask.execute(query, function (results) { //parse results and add to autocomplete widget $.each(results.features, function (index, value) { $('#selectpickerValues').append($('<option>', { value: value.attributes.CALWNUM, text: value.attributes.CALWNUM })); pickerValues = value.attributes.CALWNUM; }); }); }); });
Drop down:
<select id="selectpickerValues" class="form-control"></select>
Solved! Go to Solution.
nevermind this worked:
$(document.body).on('change', "#selectpickerValues", function (e) { //doStuff pickerValues = $("#selectpickerValues option:selected").val(); });
nevermind this worked:
$(document.body).on('change', "#selectpickerValues", function (e) { //doStuff pickerValues = $("#selectpickerValues option:selected").val(); });