Select to view content in your preferred language

Prepopulated dropdown by query select value onchange

3554
1
Jump to solution
11-10-2015 09:08 AM
AlexGole
Occasional Contributor II

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>
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
AlexGole
Occasional Contributor II

nevermind this worked:

$(document.body).on('change', "#selectpickerValues", function (e) {
                                     //doStuff
                                     pickerValues = $("#selectpickerValues option:selected").val();
                                 });

View solution in original post

0 Kudos
1 Reply
AlexGole
Occasional Contributor II

nevermind this worked:

$(document.body).on('change', "#selectpickerValues", function (e) {
                                     //doStuff
                                     pickerValues = $("#selectpickerValues option:selected").val();
                                 });
0 Kudos