AnsweredAssumed Answered

Turn on all or turn off all Checkboxes

Question asked by jay.kapalczynski on Dec 4, 2018
Latest reply on Dec 4, 2018 by rscheitlin

I have an accordion style section that contains content panes with layers inside them for the user to turn on and off

As seen below there are 5 content panes


I am building a layer list that has checkboxes built on the fly with JavaScript.

   I am using this on each FeatureLayer to determine which one it goes into: 

         legendLayers4.push({ layer: RailYards, title: 'Rail Yards' });

I added a button to the each of their content panes to be used to check all boxes or uncheck all boxes


What I am trying to do now is turn on all layers in that specific content pane by clicking the BUTTON or turning them all off by clicking the same BUTTON

I can handle all the little stuff but just cant see to get control of them in Javascript....


How do I test each checkbox...I can return their Layer title and Layer ID etc but can seem to be able to get the actual checkbox reference to test if it is checked or not...If I can get that far I can handle the button etc

I am trying to get to the individual checkboxes in document.getElementById("FeaturesButton").onclick = function () { 


You can see below that I am looping trough the legendLayers4 and creating a checkbox and label for each checkbox to be created.



<div id="IDAccordionPaneLayers" data-dojo-type="dijit.layout.AccordionContainer" style="color:black; height:50%; width:90%;">                    
<!-- SNIP  -->

        <div id="idLayers4" data-dojo-type="dijit.layout.ContentPane"  data-dojo-props="title:'Features'" selected="true" >
          <button type="button" id="FeaturesButton" style="float: right;" >Click Me!</button>
          <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'Natural Disasters'">
               <div id="toggle4" style="padding: 2px 2px; color:Black;"></div>

<!-- SNIP  -->



legendLayers4.push({ layer: RailYards, title: 'Rail Yards' });     

arrayUtils.forEach(legendLayers4, function (layer) {
     var layerName = layer.title;
     var checkBox = new CheckBox({
          name: "checkBox" +,
          checked: layer.layer.visible
     checkBox.on("change", function () {
          var targetLayer = map.getLayer(this.value);
          this.checked = targetLayer.visible;
     //add the check box and label to the toc, dom.byId("toggle4"), "after");
     var checkLabel = domConstruct.create('label', {
          innerHTML: layerName
          }, checkBox.domNode, "after");"<br />", checkLabel, "after");

document.getElementById("FeaturesButton").onclick = function () {

     arrayUtils.forEach(legendLayers4, function (layer) {
          var layerName = layer.title;
          //alert (layerName);
          var layerID =;
          var i;
          for (i = 0; i < layerID.length; i++) {
               //myNodelist[i].style.backgroundColor = "red";