title: Error Unable to get property 'options' of undefined or null reference
body: <pre><code>  function Validate() {
          for (var i = 0; i &lt; 2; i++) {
              var objCat = document.getElementById("ddlCategories" + i);
                  if (objCat.options[objCat.selectedIndex].text != "--SET--") {
                      for (var j = i + 1; j &lt; 6; j++) {
                          var objCatNext = document.getElementById("ddlCategories" + j);
                          if (objCat.options[objCat.selectedIndex].text == objCatNext.options[objCatNext.selectedIndex].text) {
                              spnMessage.innerHTML = objCatNext.options[objCatNext.selectedIndex].text + " exists.";
                              return false;
                         }
                      }
                  }             
          }
          return true;
      }
  </code></pre>
  
  <p>I have the above Javascript code that is working fine in Chrome but throws the following exception in IE 11.</p>
  
  <blockquote>
    <p>Error: Unable to get property 'options' of undefined or null reference</p>
  </blockquote>
  
  <p>I have tried to first check if objCat is not null or undefined but the exception is still being thrown, again only in IE.</p>
  
  <pre><code>function Validate() {
          for (var i = 0; i &lt; 2; i++) {
              var objCat = document.getElementById("ddlCategories" + i);
              if (objCat) { //check if objCat is not null or undefined but this has solved the issue.
                  if (objCat.options[objCat.selectedIndex].text != "--SET--") {
                      for (var j = i + 1; j &lt; 6; j++) {
                          var objCatNext = document.getElementById("ddlCategories" + j);
                          if (objCat.options[objCat.selectedIndex].text == objCatNext.options[objCatNext.selectedIndex].text) {
                              spnMessage.innerHTML = objCatNext.options[objCatNext.selectedIndex].text + " exists.";
                              return false;
                         }
                      }
                }  }             
          }
          return true;
      }
  </code></pre>
  
  <p>Is any body noticing a possible cause?</p>
  
  <p><strong>Below is the html generated when you view the page's source in the browser</strong></p>
  
  <pre><code>&lt;select name="ddlCategories0" onchange="javascript:setTimeout(&amp;#39;__doPostBack(\&amp;#39;ddlCategories0\&amp;#39;,\&amp;#39;\&amp;#39;)&amp;#39;, 0)" id="ddlCategories0" class="input Width250" onclick="Clear()"&gt;
  &lt;option value="0"&gt; --SELECT--&lt;/option&gt;
  &lt;option selected="selected" value="2"&gt;One&lt;/option&gt;
  &lt;option value="3"&gt;Two&lt;/option&gt;
  &lt;/select&gt;
  
   &lt;select name="ddlCategories1" onchange="javascript:setTimeout(&amp;#39;__doPostBack(\&amp;#39;ddlCategories1\&amp;#39;,\&amp;#39;\&amp;#39;)&amp;#39;, 0)" id="ddlCategories1" class="input Width250" onclick="Clear()"&gt;
  &lt;option value="0"&gt; --SELECT--&lt;/option&gt;
  &lt;option value="2"&gt;One&lt;/option&gt;
  &lt;option selected="selected" value="3"&gt;Two&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>