title: JSON result in to select option
body: <p>In my HTML page i have 2 select.
  When i change the value into the first select the second select must be change is option value.</p>
  
  <p>Error in console :</p>
  
  <pre><code>Uncaught ReferenceError: Invalid left-hand side in assignment
  </code></pre>
  
  <p>If i add <code>console.log(result)</code> i see the object in console.</p>
  
  <p><strong>JS code</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function changeoption() {
      $.getJSON('users.php', {nameUser:$('#nameUser').val()}, function(result) {
      var select = $('#email');
      var options = select.attr('options');
      $('option', select).remove();
          $.each(result, function(index, array) {
              $('option', select) = new Option(array['email']); // the line error
          });
      });
  }
  
  
  $(document).ready(function() { 
      changeoption();
      $('#userName').change(function() {
          changeoption();
      });
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP code</strong></p>
  
  <pre><code>&lt;?php
  
  $result = array();
  
  if(isset($_GET['userName'])) {
      $query = $dbh-&gt;prepare("SELECT email FROM tbl_users WHERE username = ? ORDER BY userId");
      $query-&gt;execute(array($_GET['userName']));
      $result = $query-&gt;fetchAll(PDO::FETCH_ASSOC);
  }
  
  echo json_encode($result);
  ?&gt;
  </code></pre>
  
  <p><strong>HTML code</strong></p>
  
  <pre><code>&lt;form&gt;
  &lt;!-- first select populated by another query inside this page--&gt;
  &lt;select name="userName" id="userName"&gt;
  &lt;option&gt;Name1&lt;/option&gt;
  &lt;option&gt;Name2&lt;/option&gt;
  &lt;option&gt;Name3&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;!-- second select --&gt;
  &lt;select name="email" id="email"&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>