title: Form with JSON and PHP. Filter according to the value of select
body: <p>Im having a problem with a form that I need to get the data of a JSON with PHP (because it is an api and I must hide the request url).</p>
  
  <p>I have 3 selects:</p>
  
  <pre><code>        &lt;select name="state" id="state"&gt;
              &lt;option value="" select&gt;STATE&lt;/option&gt;
          &lt;/select&gt;
  
          &lt;select name="city" id="city"&gt;
              &lt;option value="" select&gt;CITY&lt;/option&gt;
          &lt;/select&gt;
  
          &lt;select name="company" id="company"&gt;
              &lt;option value="" select&gt;COMPANY&lt;/option&gt;
          &lt;/select&gt;
  </code></pre>
  
  <p>Json has the companies with their respective data:</p>
  
  <pre><code>"companies": [
  {
      "company": "name x",
      "city": "sao paulo",
      "state": "SP"
  }, 
  {
      "company": "name y",
      "city": "belo horizonte",
      "state": "MG"
  }, 
  {
      "company": "name z",
      "city": "sao paulo",
      "state": "SP"
  } ]
  </code></pre>
  
  <p>What I need:</p>
  
  <p>1 - select #state: Display all states (without repetition).</p>
  
  <p>2 - select #city: Display all cities according to the selected state above.</p>
  
  <p>3 - select #company: Display all companies according to the city selected above.</p>
  
  <p>How should I do?
  I think I should use ajax requesting the php file with json embedded in it, but I dont know how to do it.</p>
  
  <p>Important: I cant change the structure of JSON because it is an api that I dont have access to modifications.</p>
  
  <p>Any good souls to help me with this?</p>
  
  <p>Thank you.</p>