title: Fire "onchange" event on page from google chrome extension
body: <p>I am developing an extension to autofill a form with data from another website.
  I have a context menu with different options, each with different data but complete the same form. The data is dynamic and depend on another website. With "chrome.tabs.executeScript" i can insert some data, but i can not fire the event "onchange" of the fields.
  Can change the value of a select, but the website has an event "onchange" that does not fire when I change the value, and not get through "chrome.tabs.executeScript" run the "onchange". The error it shows is: "Uncaught TypeError: Property 'onchange' of object # is not a function #HTMLSelectElement"</p>
  
  <p>EDIT:</p>
  
  <p>manifest.json:</p>
  
  <pre><code>"content_scripts": [
      {
          "matches": ["url_where_the_code_must_run"],
          "js": ["billing.class.js", "script.js"]
      }
  ],
  .
  .
  .
  
  "permissions": [
      "tabs",
      "url_from_where_i_get_the_data",
      "url_where_the_code_must_run"
  ],
  </code></pre>
  
  <p>script.js:</p>
  
  <pre><code>select = document.createElement('select');
  var option = document.createElement('option');
  option.value = "";
  option.innerHTML = "Select Client";
  select.appendChild(option);
  select.onchange = function() {
      var client = Billing.getClient(this.value);
      if (client) {
          document.getElementsByName("country")[0].value = client.country_id;
          document.getElementsByName("country")[0].onchange();
      }
  }
  for (var i = 0; i &lt; Billing.clients.length; i++) {
      option = document.createElement('option');
      option.value = Billing.clients[i].id;
      option.innerHTML = Billing.clients[i].name;
      select.appendChild(option);
  }
  
  form.parentElement.insertBefore(select, form);
  </code></pre>
  
  <p>When this line is executed, show "Uncaught TypeError: Property 'onchange' of object # is not a function #HTMLSelectElement":</p>
  
  <pre><code>document.getElementsByName("country")[0].onchange();
  </code></pre>
  
  <p>But if I run this line directly in the console, normally runs without errors</p>
  
  <p>document.getElementsByName("country")[0] is an element of the url, and "select" is an element that i create in the extension to select what client data should load.</p>
  
  <p>url_where_the_code_must_run:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
         function customFunction() {
              // Do something that i dont care
         }
  &lt;/script&gt;
  &lt;select name="country" onchange="customFunction()"&gt;
  &lt;/select&gt;
  </code></pre>