title: "Uncaught TypeError: Cannot read property 'toString' of null"
body: <p>When I debug this code, I get this error on the "else" part of the if-statement. I am not very familiar with java script so any help would be great :)</p>
  
  <pre class="lang-js prettyprint-override"><code>function doDDItemSelected() {
      var oSrc = event.srcElement
      var oCrit
      var oCritB
      var lstListItems
      var iCritPK = oSrc.getAttribute('CRIT_PK')
      oSrc.style.visibility = "hidden";
      oSrc.style.display = "none";
  
      if (oSrc.id.indexOf("lstCritB") != -1) {
          oCrit = $get('CritB' + iCritPK.toString());
          oCrit.value = oSrc.options[oSrc.selectedIndex].text;
      } else {
          oCrit = $get('Crit' + iCritPK.toString()); // error is in this line
          oCrit.value = oSrc.options[oSrc.selectedIndex].text;
          if (oCrit.onchange) {
              oCrit.onchange();
          }
  
          // Set the value of the end of range field if there is one
          try {
              oCritB = $get('CritB' + iCritPK.toString());
              if (oCritB.value == "") {
                  if (oSrc.options[oSrc.selectedIndex].value != "(ALL)") {
                      oCritB.value = oSrc.options[oSrc.selectedIndex].text;
                  }
              }
          } catch (e) {
              return;
          }
      }
  }
  </code></pre>
  
  <p>Edit: I should add that this function is used in a selecting a drop down box in a web browser. The issue is that I cannot select items in the drop down box and have the selected item displayed in the same box. This code works in IE11 but not in Google Chrome.</p>
  
  <p>Edit 2: Here is a screenshot of the debugger in google chrome
  <a href="https://i.stack.imgur.com/2IIBk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2IIBk.png" alt="enter image description here"></a></p>