<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Access Layer Checked Box in ESRI Web Map Template in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-layer-checked-box-in-esri-web-map-template/m-p/311604#M28666</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to write a JavaScript that accesses a layer that has a checked box in the ESRI Public Information web map template, but I'm not having success.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To figure out what to put in my query selectors, I'm right clicking the checked box in the layers panel to inspect the element and open up the developer console. According to the console, checked boxes should have a div class name of "&lt;SPAN style="color: #222222; font-family: Consolas, 'Lucida Console', monospace; font-size: 12px; font-style: normal; font-weight: normal; text-align: left; text-indent: 0px;"&gt;toc-checkbox icon-check-1".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;But when I write a code to test if this class exists (code below) in main.js, it says the class does not exist (console.log message doesn't appear). I'm also getting an error that says &lt;STRONG&gt;clickLayers.addEventListener is not a function.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Test Code to Access Checked box:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if (this.config.enablecheckboxclick) {&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt; //created this myself; enabled checkboxclick in defaults.js as true&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
function mapLoaded () {&amp;nbsp;&amp;nbsp;&amp;nbsp; 
console.log("map loaded"); //show after map loads

function getCheckedLayers() {
&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;console.log("clicked on a checkbox");&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt; //show when click on checkbox in layers panel&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
}

var clickLayers = document.getElementsByClassName('div.toc-checkbox'); //check box class name = "div.toc-checkbox"; if i do getElementById("#mapDiv") it works
clickLayers.addEventListener('click', getCheckedLayers, false); //when click on checkbox, call getCheckedLayers
&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;}&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; window.addEventListener('load', mapLoaded, false); 
&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt; }&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Links:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Link to the GitHub to download template: &lt;A href="https://github.com/Esri/public-information-map-template-js" title="https://github.com/Esri/public-information-map-template-js" rel="nofollow noopener noreferrer" target="_blank"&gt;Esri/public-information-map-template-js · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Link to the live map showing template: &lt;A href="http://esri.github.io/public-information-map-template-js/" title="http://esri.github.io/public-information-map-template-js/" rel="nofollow noopener noreferrer" target="_blank"&gt;Public Information Map&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Background Information:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Novice Developer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I access layers that have been checked in the Public Information Template using JavaScript or CSS queries?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:54:09 GMT</pubDate>
    <dc:creator>LisCollins</dc:creator>
    <dc:date>2021-12-11T14:54:09Z</dc:date>
    <item>
      <title>Access Layer Checked Box in ESRI Web Map Template</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-layer-checked-box-in-esri-web-map-template/m-p/311604#M28666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to write a JavaScript that accesses a layer that has a checked box in the ESRI Public Information web map template, but I'm not having success.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To figure out what to put in my query selectors, I'm right clicking the checked box in the layers panel to inspect the element and open up the developer console. According to the console, checked boxes should have a div class name of "&lt;SPAN style="color: #222222; font-family: Consolas, 'Lucida Console', monospace; font-size: 12px; font-style: normal; font-weight: normal; text-align: left; text-indent: 0px;"&gt;toc-checkbox icon-check-1".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;But when I write a code to test if this class exists (code below) in main.js, it says the class does not exist (console.log message doesn't appear). I'm also getting an error that says &lt;STRONG&gt;clickLayers.addEventListener is not a function.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Test Code to Access Checked box:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if (this.config.enablecheckboxclick) {&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt; //created this myself; enabled checkboxclick in defaults.js as true&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
function mapLoaded () {&amp;nbsp;&amp;nbsp;&amp;nbsp; 
console.log("map loaded"); //show after map loads

function getCheckedLayers() {
&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;console.log("clicked on a checkbox");&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt; //show when click on checkbox in layers panel&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
}

var clickLayers = document.getElementsByClassName('div.toc-checkbox'); //check box class name = "div.toc-checkbox"; if i do getElementById("#mapDiv") it works
clickLayers.addEventListener('click', getCheckedLayers, false); //when click on checkbox, call getCheckedLayers
&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;}&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; window.addEventListener('load', mapLoaded, false); 
&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt; }&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Links:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Link to the GitHub to download template: &lt;A href="https://github.com/Esri/public-information-map-template-js" title="https://github.com/Esri/public-information-map-template-js" rel="nofollow noopener noreferrer" target="_blank"&gt;Esri/public-information-map-template-js · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Link to the live map showing template: &lt;A href="http://esri.github.io/public-information-map-template-js/" title="http://esri.github.io/public-information-map-template-js/" rel="nofollow noopener noreferrer" target="_blank"&gt;Public Information Map&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Background Information:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Novice Developer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I access layers that have been checked in the Public Information Template using JavaScript or CSS queries?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:54:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-layer-checked-box-in-esri-web-map-template/m-p/311604#M28666</guid>
      <dc:creator>LisCollins</dc:creator>
      <dc:date>2021-12-11T14:54:09Z</dc:date>
    </item>
  </channel>
</rss>

