title: Uncaught TypeError: Cannot read property 'dispatchEvent' of null
body: <p>I am getting the above error when I run my function. The goal is when a user enters a number in a  search box it should zoom to that number in the visualization. Below is my code -</p>
  <pre><code>function zoom1() {
   var input1 = document.getElementById(&quot;myInput1&quot;).value; //value from searchbox
    console.log(&quot;input from searchbox :&quot;+input1);
  
   d3.json(&quot;intervals.json&quot;, function(alldata)  // entering json file  to look for oid
   {
      // console.log(&quot;all data from json&quot;+alldata);
      var i=0;
      for (i = 0; i &lt; alldata.records.length; i++)  //for loop for getting the &quot;oid&quot;  alldata.records.length;
      {
      
        conceptid1 = alldata.records[i].eag;  //saving all the oid in conceptid
        console.log(&quot;conceptid1: &quot;+conceptid1);
        var conceptid2 = conceptid1.toString();
        console.log(&quot;conceptid2: &quot;+conceptid2);
        if (conceptid2  === input1) //if the user input1 matches conceptid2
        {
           console.log(&quot;inside if conceptid2:&quot;+conceptid2);
          
           console.log(document.getElementById(conceptid2).dispatchEvent(new Event('click'))); // zoom
        }
  
      }
  
   });
  }
  </code></pre>