title: PHP Populate Text Box from DropDown Selection
body: <p>I am trying to populate two text fields after a user makes a choice on a drop down.
  the code below works but is obviously a manual effort in the function.
  I need the values for form.accounts and form.client to come from the query the select box is using.
  Any ideas.
  Should this be jquery - not really familiar with it.</p>
  
  <pre><code>&lt;?php                          
  $db = new mysqli("127.0.0.1", "root", "", "centrum");
  
  $sql = "SELECT
  accounts_client_accounts.accounts_client_account_id,
  accounts_client_accounts.accounts,
  accounts_client.client
  FROM
  accounts_client_accounts
  INNER JOIN accounts_client ON accounts_client_accounts.accounts_client_id =      accounts_client.accounts_client_id
  ORDER BY accounts_client_account_id
  ";
  
  if(!$result = $db-&gt;query($sql)){
  die('There was an error running the query [' . $db-&gt;error . ']');
  }?&gt;
  
  &lt;form class="form-ui"&gt;
  &lt;span class="form-elements reqField"&gt;
    &lt;select class="dropdown" onchange="populateData(this)"&gt;
     &lt;option value="0"&gt;Choose Account&lt;/option&gt;
   &lt;?php while($row = $result-&gt;fetch_assoc()){ 
  
    echo "&lt;option value='". $row['accounts_client_account_id']."'&gt;".$row['accounts'];
    }
    ?&gt;
    &lt;/select&gt;
  &lt;/span&gt;
  &lt;span class="form-elements"&gt;
    &lt;input name="accounts" type="text" class="text" value="" /&gt;
  &lt;/span&gt;
  
  &lt;span class="form-elements reqField"&gt;
    &lt;input name="client" type="text" class="text" value="" /&gt;
  &lt;/span&gt;
  &lt;/form&gt;
  &lt;script&gt;
  function populateData(sel){
      var form = sel.form,
          value = sel.options[sel.selectedIndex].value;
      switch(value){
          case '1':
              form.accounts.value = 'Account1';
              form.client.value = 'Client1';
          break;
          case '2':
              form.accounts.value = 'Account2';
              form.client.value = 'Client2';
          break;
          case '3':
           form.accounts.value = 'Account3';
              form.client.value = 'Client3';
          break;
          default:
      }
  }
  &lt;/script&gt;
  </code></pre>