title: Javascript simulate pressing enter in input box
body: <p>I have what seemed to be a simple fix to a problem but after trying a ton of different solutions online nothing seems to work for me.</p>
  
  <p>I have search field that searches a data table every time you type or press enter in the input field, however after I assigned a value to the search box when the page is loaded it wont do the search until after the user either presses enter in the box or types / deletes a letter.  I was just trying to find a solution to simulate hitting enter but it didn't seem to work.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
         window.onload = (function() {
             document.getElementById('search').value = " &lt;?php echo $search;?&gt;";
  
         });
  &lt;/script&gt;
  </code></pre>
  
  <p>This obviously assigns the value to what my php variable is set to which works fine the text is loaded in the box on page load, it just doesnt perform the search like I said unless the user presses enter in the box OR deletes/adds a letter in the input box.</p>
  
  <p>The search box code is </p>
  
  <pre><code>&lt;input type="text" id="search" aria-controls="DataTables_Table_0" class="text"&gt;
  </code></pre>
  
  <p>Update: This is documentation I found on exactly what I am using <a href="http://datatables.net/ref" rel="nofollow">http://datatables.net/ref</a></p>