title: Auto-fill Form Select Fields from External API using HTTP GET
body: <p>I'm trying to link up a HTML/PHP form from a WordPress site to communicate with an external database (which is built using Ruby on Rails I believe). I have been told this DB has a fully working API.</p>
  
  <p>The full form has a few other standard text fields etc, but to give a basic overview, the user would select a make of car in the 'make_field' below. This would then communicate with the database's API to fill out options for the next select 'inquest_model' (and then based on that, there would be another call which would populate the 'inquest_year' field).</p>
  
  <pre><code>&lt;form accept-charset="UTF-8" action="http://runbikestop.com/inquests" class="new_inquest" id="new_inquest" method="post"&gt;
  
        &lt;div class="field" id="make_field"&gt;
           &lt;label for="inquest_make"&gt;Make &lt;span class="please-wait"&gt;please wait&lt;/span&gt;&lt;/label&gt;
           &lt;select id="inquest_make" name="inquest[make]"&gt;&lt;option value=""&gt;Please select&lt;/option&gt;
             &lt;option value="ABARTH"&gt;ABARTH&lt;/option&gt;
             &lt;option value="ALFA ROMEO"&gt;ALFA ROMEO&lt;/option&gt;
             &lt;option value="AUDI"&gt;AUDI&lt;/option&gt;
             &lt;!--(there are 100 or so more options here...)--&gt;
          &lt;/select&gt;
         &lt;/div&gt;
  
         &lt;div class="field"&gt;
           &lt;label for="inquest_make"&gt;Model &lt;span class="please-wait"&gt;please wait&lt;/span&gt;&lt;/label&gt;
           &lt;select id="inquest_model" name="inquest[model]"&gt;
             &lt;option&gt; &lt;/option&gt;
           &lt;/select&gt;
         &lt;/div&gt;
  
         &lt;div class="field" id="year_field"&gt;
            &lt;label for="inquest_make"&gt;Year &lt;span class="please-wait"&gt;please wait&lt;/span&gt;&lt;/label&gt;
            &lt;select id="inquest_year" name="inquest[year]"&gt;
             &lt;option&gt; &lt;/option&gt;
           &lt;/select&gt;
         &lt;/div&gt;
  
          &lt;input id="inquest_gclid_code" name="inquest[gclid_code]" type="hidden" /&gt;
          &lt;input id="inquest_webpage_url" name="inquest[webpage_url]" type="hidden" /&gt;
  
         &lt;div class="actions"&gt;
           &lt;input name="commit" type="submit" value="Submit" /&gt;
         &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I've been told by the ruby developer who built the database that the following are the types of command line test queries that would need to be made to get the dynamic drop-downs to work:</p>
  
  <pre><code>curl -i -H "Accept: application/json"  http://runbikestop.com/api/v1/cars/models?makes=ALFA+ROMEO 
  curl -i -H "Accept: application/json" "http://runbikestop.com/api/v1/cars/car_years?makes=ALFA+ROMEO&amp;models=156"
  </code></pre>
  
  <p>The other developer recommended against using javascript API calls and instead suggested HTTP get requests/calls...? I'm just not sure what the best way would be to get this all working, so if someone could point me in the right direction that would be appreciated!</p>