AnsweredAssumed Answered

if nothing is selected select first value dropdown JQuery

Question asked by AlexSabrina on Nov 9, 2015
Latest reply on Nov 9, 2015 by AlexSabrina

Hi all,

I have multiple dropdowns from which I can select Township/range and section values that are used for queries. It does the job when I change the values of the drop downs but when nothing is selected (no change) in the drop down then NO value is selected. Any idea how to get the current value and then the onchange value if users change value on drop downs?

Query:

var picker1;
                         var picker2;
                         var picker3;
                         var picker4;
                         var picker5;




                         $("#selectpicker1").change(function () {
                             picker1 = this.value;
                             alert(this.value);
                         });
                         $("#selectpicker2").change(function () {
                             picker2 = this.value;
                             alert(this.value);
                         });
                         $("#selectpicker3").change(function () {
                             picker3 = this.value;
                             alert(this.value);
                         });
                         $("#selectpicker4").change(function () {
                             picker4 = this.value;
                             alert(this.value);
                         });
                         $("#selectpicker5").change(function () {
                             picker5 = this.value;
                             alert(this.value);
                         });





on(dom.byId("Query1"), "click", queryPLSS);
                         function queryPLSS() {
                             var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/ResourceMgmt/WatershedMapper10_2/MapServer/0");
                             queryTask.on("complete", addToMap);
                             var query = new Query();
                             query.returnGeometry = true;
                             query.outFields = ["TOWNSHIP", "RANGE", "SECTION"];
                             query.where = "TOWNSHIP='" + picker1 + picker2 + "' AND " + "RANGE='" + picker3 + picker4 + "' AND " + "SECTION=" + picker5;
                             query.outSpatialReference = map.spatialReference;
                             queryTask.execute(query, function (featureSet) {
                                 var AOI = featureSet.features[0].geometry;
                                 var graphic = new Graphic(AOI, symbol8);
                                 var features = [];
                                 features.push(graphic);
                                 var fSet = new FeatureSet();
                                 fSet.features = features;
                                 console.log("Querying...");
                             });

 

Thanks,

Alex

Outcomes