title: Two dropdowns filled dynamically from mysql
body: <p>I have a dropdown that is filled by a database mysql and everything runs well. Then I have a second dropdown that is filled also by a database upon the selection from the first dropdown. 
  Two problems: </p>
  
  <ol>
  <li>The first item from dropdown 1 doesn't fill dropdown </li>
  <li>If I select
  an item from dropdown 1, it gives me the items to dropdown 2, of the
  last item in dropdown 1.</li>
  </ol>
  
  <p>Can someone help?1
  This is my code:</p>
  
  <pre><code>&lt;select id="categoria" onChange="selectServ()"&gt;
  &lt;option value="item" class="itemoption"&gt;Categoria&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;select id="servicos"&gt;
  &lt;option value="item" class="itemoption"&gt;Serviço&lt;/option&gt;
  
  &lt;/select&gt;
  &lt;script&gt;
  $(function(){
  
    var items="";
    $.getJSON("http://example.com/servicos_categorias.php",function(data){
  
      $.each(data,function(index,item) 
      {
        items+="&lt;option value='"+item.ID+"'&gt;"+item.categoria+"&lt;/option&gt;";
      });
      $("#categoria").html(items); 
    });
  });
  
  &lt;/script&gt;
  &lt;script&gt;
  function selectServ(){
      var e = document.getElementById("categoria");
      var servSelected = e.options[e.selectedIndex].value;
  
      var url = "";
  
    var items="";
    if(servSelect = 1){
    url = "http://example.com/servicos_threading.php";
    }
    if(servSelect = 2){
    url = "http://example.com/servicos_sobrancelhas.php";
    }
    if(servSelect = 3){
    url = "http://example.com/servicos_manicure.php";
    }
    $.getJSON(url,function(data){
  
      $.each(data,function(index,item) 
      {
        items+="&lt;option value='"+item.ID+"'&gt;"+item.servico+"&lt;/option&gt;";
      });
      $("#servicos").html(items); 
    });
  };
  
  &lt;/script&gt;
  </code></pre>
  
  <p>tried also to use this:</p>
  
  <pre><code>    if(servSelect = 1){
    url = "http://example.com/servicos_threading.php";
    }
    else if(servSelect = 2){
    url = "http://example.com/servicos_sobrancelhas.php";
    }
    else if(servSelect = 3){
    url = "http://example.com/servicos_manicure.php";
    }
  </code></pre>
  
  <p>But then it doesn't fill both drop downs.</p>