title: PHP/JSON Array display values based on dropdown selection
body: <p>Having a difficult time trying to suss this out. I've searched through, but I'm not sure if the phrase I'm using to search is correct or not.</p>
  
  <p>I have a JSON file that I'm using to bring in an array of data from an outside source. Using PHP, I decode the contents. I've created a dropdown box that will display the keys, but what I'm looking to do now is dynamically populate a printout with the different values that the keys are attached to based on what the select box has selected.</p>
  
  <pre><code>    &lt;?php
    // JSON string
    $json = file_get_contents("showrace.json");
    $races = json_decode($json, true);
  ?&gt;
      &lt;select id="raceSelect"&gt;
        &lt;option value="select one" selected&gt;Select One&lt;/option&gt;
        &lt;?php foreach($races as $key =&gt; $value) { ?&gt;
          &lt;option value="&lt;?php echo $key ?&gt;"&gt;&lt;?php echo $value['race'] ?&gt;&lt;/option&gt;
        &lt;?php } ?&gt;
      &lt;/select&gt;
      &lt;div id="template"&gt;
          Str Plus: #   Dex Plus: #   Wis Plus: #   Int Plus: #&lt;br&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>And here is a sample of what the JSON file looks like:</p>
  
  <pre><code>{
  "Ithorian":{"price":0,"wis":3,"str":2,"lck":0,"int":2,"frc":0,"dex":-2,"con":2,"cha":-3,"app":"No","hp":1200,"ac":0,"race":"Ithorian","lang":"ithorian"},
  "Weequay":{"price":1000,"wis":-2,"str":3,"lck":0,"int":-2,"frc":0,"dex":0,"con":2,"cha":-3,"app":"No","hp":1350,"ac":0,"race":"Weequay","lang":"weequay"}
  }
  </code></pre>
  
  <p>In the first snippet, the #'s in the template div will be outputs for the JSON values such as "str" and "dex" and such. While I was able to find out how to set the select to draw in the keys from the JSON, I am baffled at how to populate the template portion with the corresponding values, based off of the selected item.</p>
  
  <p>Thanks in advance!</p>