Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

uncaught type error,cannot set property '.innerhtml' of null

We are using this code in our project. but this code is not working in our project. We already used this code in our previous project, at that time this code was properly worked. In this code,count of every device will get through using stored procedure,but this count is not displayed using our javascript code.

function _updateDeviceCount() {
          var markers = [
                        ["ActiveDevices", 10],
                        ["Gasclam", 4],
                        ["Falcon", 6]
                  ];
   
            console.log("inside device count");
            for (i = 0; i < markers.length; i++) 
            {
            
              for(j=0; j< markers.length;j++)
              {

                  if (markers[i][j] == "Falcon") {
                      document.getElementById('lbl_dev_count_falcon').innerHTML = markers[i][j+1];
                  }
                  else if (markers[i][j] == "Gasclam") {
                      document.getElementById('lbl_dev_count_gasclam').innerHTML = markers[i][j+1];
                  }
                  else if (markers[i][j] == "ActiveDevices") {
                      document.getElementById('lbl_dev_count_all').innerText = markers[i][j+1];
                  }
              }
     }
}
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  </head>
  <body>
     <div class="item active">
     
        <div class="col-md-4 col-xs-offset-2"> 
          <label>
            All: 
          </label>
        </div>
        
        <div class="col-md-6">
          <label ID="lbl_dev_count_all"  runat="server">
          </label>
        </div>
       
      </div>

      <div class="item">
      
       <div class="col-md-4 col-xs-offset-2">
          <label>
            Falcon: 
          </label>
        </div>
        
        <div class="col-md-6">
          <label ID="lbl_dev_count_falcon" runat="server" >
          </label>
        </div>
        
      </div>
    
      <div class="item">
      
        <div class="col-md-4 col-xs-offset-2">
          <label>
            GasClam:
          </label>
        </div>
        
        <div class="col-md-6">
          <label ID="lbl_dev_count_gasclam" runat="server" >
          </label>
        </div>
        
    </div>
  </body>
  <script language="javascript" type="text/javascript">
    $(document).ready(function () {
      _updateDeviceCount();
    })
  </script>
</html>

Comments